fix mod apk making
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.vk.sharing.view;
|
||||
|
||||
import static b.h.z.f.roboto_medium;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -32,6 +31,7 @@ import com.vk.imageloader.view.VKMultiImageView;
|
||||
import com.vk.navigation.NavigatorKeys;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.a0;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class TargetImageView extends VKMultiImageView {
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
Canvas canvas2 = this.f21631f;
|
||||
int pref = preferences.getInt("pic_rounding", 0);
|
||||
int pref = Preferences.getPreferences().getInt("pic_rounding", 0);
|
||||
|
||||
if (canvas2 != null) {
|
||||
canvas2.drawColor(0, PorterDuff.Mode.CLEAR);
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public abstract class IMProcessor {
|
||||
// By default it checks start and end tag.
|
||||
@@ -67,20 +68,20 @@ public abstract class IMProcessor {
|
||||
}
|
||||
|
||||
public void enableEncryptFor(int id) {
|
||||
AndroidUtils.getDefaultPrefs().edit().putBoolean("VT_IMEncode_" + getPrefKey() + "_" + id, true).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("VT_IMEncode_" + getPrefKey() + "_" + id, true).apply();
|
||||
}
|
||||
|
||||
public void disableEncryptFor(int id) {
|
||||
AndroidUtils.getDefaultPrefs().edit().putBoolean("VT_IMEncode_" + getPrefKey() + "_" + id, false).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("VT_IMEncode_" + getPrefKey() + "_" + id, false).apply();
|
||||
}
|
||||
|
||||
public void setEncryptionKeyFor(int id, @Nullable String key) {
|
||||
if (key == null || key.isEmpty()) key = "VTAesDefault";
|
||||
AndroidUtils.getDefaultPrefs().edit().putString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, key).apply();
|
||||
Preferences.getPreferences().edit().putString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, key).apply();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEncryptionKeyFor(int id) {
|
||||
return AndroidUtils.getDefaultPrefs().getString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, null);
|
||||
return Preferences.getPreferences().getString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class VTostersAESProcessor extends IMProcessor {
|
||||
private final static String CIPHER_INSTANCE = "AES/CBC/PKCS7Padding";
|
||||
@@ -114,7 +115,7 @@ public class VTostersAESProcessor extends IMProcessor {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getEncryptionKeyFor(int id) {
|
||||
return AndroidUtils.getDefaultPrefs().getString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, "VTAesDefault");
|
||||
return Preferences.getPreferences().getString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, "VTAesDefault");
|
||||
}
|
||||
|
||||
public static class Triple<F, S, T> {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Collections;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class AdBlockHook {
|
||||
public static Boolean discoverAdBlock(JSONObject jsonObject) {
|
||||
@@ -351,7 +352,7 @@ public class AdBlockHook {
|
||||
return true;
|
||||
}
|
||||
|
||||
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet(
|
||||
var whitelist = Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_filters_groups",
|
||||
Collections.emptySet()
|
||||
);
|
||||
@@ -366,7 +367,7 @@ public class AdBlockHook {
|
||||
id = String.valueOf(list.optInt("source_id"));
|
||||
}
|
||||
|
||||
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet(
|
||||
var whitelist = Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_ad_groups",
|
||||
Collections.emptySet()
|
||||
);
|
||||
@@ -377,7 +378,7 @@ public class AdBlockHook {
|
||||
public static Boolean isWhitelistedAdStories(JSONObject list) {
|
||||
var id = String.valueOf(list.optInt("owner_id"));
|
||||
|
||||
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet(
|
||||
var whitelist = Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_stories_ad",
|
||||
Collections.emptySet()
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getStringDate;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -15,11 +15,11 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class DateHook {
|
||||
public static boolean fulltime() {
|
||||
return getPrefsValue("dateformat").equals("noyear") || getPrefsValue("dateformat").equals("full") || getPrefsValue("dateformat").equals("noseconds");
|
||||
return getString("dateformat").equals("noyear") || getString("dateformat").equals("full") || getString("dateformat").equals("noseconds");
|
||||
}
|
||||
|
||||
public static String getDateFormat() {
|
||||
return switch (getPrefsValue("dateformat")) {
|
||||
return switch (getString("dateformat")) {
|
||||
case "noyear" -> AndroidUtils.getString(R.string.fulltime2);
|
||||
case "full" -> AndroidUtils.getString(R.string.fulltime);
|
||||
default -> AndroidUtils.getString(R.string.fulltime3);
|
||||
@@ -45,7 +45,7 @@ public class DateHook {
|
||||
}
|
||||
|
||||
public static String getLocale() {
|
||||
String string = getPrefsValue("lang_value");
|
||||
String string = getString("lang_value");
|
||||
|
||||
if (string.equals("system")) {
|
||||
return Locale.getDefault().getLanguage();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.ui.components.FragAnimationKit.setAnimations;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
@@ -9,7 +9,7 @@ public class FragAnimationHook {
|
||||
public static boolean animateOpen(FragmentTransaction transaction) {
|
||||
setAnimations(transaction);
|
||||
|
||||
return getPrefsValue("anim_rtrn_type").equals("noanim") || getPrefsValue("anim_rtrn_type").isEmpty();
|
||||
return getString("anim_rtrn_type").equals("noanim") || getString("anim_rtrn_type").isEmpty();
|
||||
}
|
||||
|
||||
public static void animateClose(FragmentTransaction transaction) {
|
||||
|
||||
@@ -1,37 +1,22 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.foaf.FoafBase.getBypassedOnlineInfo;
|
||||
import static ru.vtosters.lite.hooks.OnlineFormatterHook.onlineHookProfiles;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getStatic;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsblock;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isDeveloper;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.vk.core.util.LangUtils;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import static ru.vtosters.lite.foaf.FoafBase.getBypassedOnlineInfo;
|
||||
import static ru.vtosters.lite.hooks.OnlineFormatterHook.onlineHookProfiles;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsblock;
|
||||
|
||||
public class JsonInjectors {
|
||||
public static JSONObject menu(JSONObject orig) throws JSONException {
|
||||
@@ -47,7 +32,7 @@ public class JsonInjectors {
|
||||
}
|
||||
|
||||
public static JSONObject superapp(JSONObject json) throws JSONException {
|
||||
var superApps = AndroidUtils.getPreferences().getString("superapp_items",
|
||||
var superApps = Preferences.getPreferences().getString("superapp_items",
|
||||
"menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run").split(",");
|
||||
if (superApps.length == 0) return json;
|
||||
|
||||
@@ -154,8 +139,8 @@ public class JsonInjectors {
|
||||
}
|
||||
|
||||
public static JSONArray newsfeedlist(JSONArray items) throws JSONException {
|
||||
var selectedItems = getDefaultPrefs().getString("news_feed_selected_items", "");
|
||||
var filtersSet = getDefaultPrefs().getStringSet("news_feed_items_set", null);
|
||||
var selectedItems = Preferences.getPreferences().getString("news_feed_selected_items", "");
|
||||
var filtersSet = Preferences.getPreferences().getStringSet("news_feed_items_set", null);
|
||||
var mutableFiltersSet = new LinkedHashSet<String>();
|
||||
if (filtersSet != null)
|
||||
mutableFiltersSet.addAll(filtersSet);
|
||||
@@ -182,7 +167,7 @@ public class JsonInjectors {
|
||||
.put("is_unavailable", hide);
|
||||
if (dev()) Log.d("NewsfeedListInj", "Unlocked " + id + " in newsfeed list");
|
||||
}
|
||||
getDefaultPrefs().edit().putStringSet("news_feed_items_set", mutableFiltersSet)
|
||||
Preferences.getPreferences().edit().putStringSet("news_feed_items_set", mutableFiltersSet)
|
||||
.apply();
|
||||
|
||||
return items;
|
||||
|
||||
@@ -18,8 +18,6 @@ import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest;
|
||||
import static ru.vtosters.lite.utils.CacheUtils.getInstance;
|
||||
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
|
||||
@@ -49,63 +47,33 @@ public class MainActivityInjector {
|
||||
|
||||
// VKIDProtection.alert(activity);
|
||||
|
||||
if(Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.hasTmpArchive()) {
|
||||
if(Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) {
|
||||
Preferences.updateBuildNumber();
|
||||
updateBinsAndTmpArchive(activity, false);
|
||||
updateBinsAndTmpArchive(activity);
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateBinsAndTmpArchive(Activity activity, boolean applyAccent) {
|
||||
private static void updateBinsAndTmpArchive(Activity activity) {
|
||||
final VKProgressDialog dialog = new VKProgressDialog(activity);
|
||||
|
||||
String msg;
|
||||
Runnable task;
|
||||
if(ThemesManager.hasBins() && !applyAccent) {
|
||||
msg = "Инвалидация кэша";
|
||||
task = () -> {
|
||||
try {
|
||||
ThemesManager.deleteBins();
|
||||
ThemesManager.generateBins();
|
||||
activity.runOnUiThread(() -> {
|
||||
dialog.cancel();
|
||||
updateBinsAndTmpArchive(activity, true);
|
||||
});
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
activity.runOnUiThread(() -> {
|
||||
dialog.cancel();
|
||||
showErrorDialog(activity, "Ошибка при инвалидации кэша");
|
||||
});
|
||||
}
|
||||
};
|
||||
} else {
|
||||
msg = "Применение акцента";
|
||||
task = () -> {
|
||||
try {
|
||||
if(ThemesManager.hasTmpArchive()) ThemesManager.deleteTmpArchive();
|
||||
ThemesManager.generateTempResArchive(ThemesUtils.getReservedAccent());
|
||||
activity.runOnUiThread(LifecycleUtils::restartApplication);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
activity.runOnUiThread(() -> {
|
||||
dialog.cancel();
|
||||
showErrorDialog(activity, "Ошибка при применении акцента");
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
dialog.setMessage(msg);
|
||||
dialog.setMessage("Применение акцента");
|
||||
dialog.show();
|
||||
|
||||
VTExecutors.getIoExecutor().execute(task);
|
||||
}
|
||||
|
||||
static void showErrorDialog(Activity activity, String msg) {
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle("Ошикба")
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
VTExecutors.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
ThemesManager.generateModApk(ThemesUtils.getReservedAccent());
|
||||
activity.runOnUiThread(LifecycleUtils::restartApplication);
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
activity.runOnUiThread(() -> {
|
||||
dialog.cancel();
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle("Ошикба")
|
||||
.setMessage("Ошибка при применении акцента:\n" + e)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static java.lang.Long.MAX_VALUE;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.ads;
|
||||
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
|
||||
@@ -23,13 +22,14 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class NewsfeedHook {
|
||||
public static long getUpdateNewsfeed(boolean refresh_timeout) {
|
||||
if (vkme()) {
|
||||
return MAX_VALUE;
|
||||
}
|
||||
return switch (getPrefsValue("newsupdate")) {
|
||||
return switch (getString("newsupdate")) {
|
||||
case "no_update" -> MAX_VALUE;
|
||||
case "imd_update" -> 10000L;
|
||||
default ->
|
||||
@@ -67,20 +67,20 @@ public class NewsfeedHook {
|
||||
}
|
||||
|
||||
public static boolean isWhitelistedFilter(ExtendedCommunityProfile eup) {
|
||||
return getDefaultPrefs().getStringSet(
|
||||
return Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_filters_groups", Collections.emptySet()
|
||||
).contains(String.valueOf(AccountManagerUtils.getUserID(eup)));
|
||||
}
|
||||
|
||||
public static boolean isWhitelistedAd(ExtendedCommunityProfile eup) {
|
||||
return getDefaultPrefs().getStringSet(
|
||||
return Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_ad_groups",
|
||||
Collections.emptySet()
|
||||
).contains(String.valueOf(AccountManagerUtils.getUserID(eup)));
|
||||
}
|
||||
|
||||
public static boolean isWhitelistedAdStories(ExtendedCommunityProfile eup) {
|
||||
return getDefaultPrefs().getStringSet(
|
||||
return Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_stories_ad",
|
||||
Collections.emptySet()
|
||||
).contains(String.valueOf(AccountManagerUtils.getUserID(eup)));
|
||||
@@ -89,7 +89,7 @@ public class NewsfeedHook {
|
||||
public static void setWhitelistedFilter(ExtendedCommunityProfile eup, boolean needWhitelist) {
|
||||
var id = String.valueOf(AccountManagerUtils.getUserID(eup));
|
||||
|
||||
var mutableAdsSet = new LinkedHashSet<>(getDefaultPrefs().getStringSet(
|
||||
var mutableAdsSet = new LinkedHashSet<>(Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_filters_groups",
|
||||
Collections.emptySet())
|
||||
);
|
||||
@@ -99,13 +99,13 @@ public class NewsfeedHook {
|
||||
mutableAdsSet.remove(id);
|
||||
}
|
||||
|
||||
getDefaultPrefs().edit().putStringSet("whitelisted_filters_groups", mutableAdsSet).apply();
|
||||
Preferences.getPreferences().edit().putStringSet("whitelisted_filters_groups", mutableAdsSet).apply();
|
||||
}
|
||||
|
||||
public static void setWhitelistedAd(ExtendedCommunityProfile eup, boolean needWhitelist) {
|
||||
var id = String.valueOf(AccountManagerUtils.getUserID(eup));
|
||||
|
||||
var mutableAdsSet = new LinkedHashSet<>(getDefaultPrefs().getStringSet(
|
||||
var mutableAdsSet = new LinkedHashSet<>(Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_ad_groups",
|
||||
Collections.emptySet()));
|
||||
|
||||
@@ -115,13 +115,13 @@ public class NewsfeedHook {
|
||||
mutableAdsSet.remove(id);
|
||||
}
|
||||
|
||||
getDefaultPrefs().edit().putStringSet("whitelisted_ad_groups", mutableAdsSet).apply();
|
||||
Preferences.getPreferences().edit().putStringSet("whitelisted_ad_groups", mutableAdsSet).apply();
|
||||
}
|
||||
|
||||
public static void setWhitelistedAdStories(ExtendedCommunityProfile eup, boolean needWhitelist) {
|
||||
var id = String.valueOf(AccountManagerUtils.getUserID(eup));
|
||||
|
||||
var mutableAdsSet = new LinkedHashSet<>(getDefaultPrefs().getStringSet(
|
||||
var mutableAdsSet = new LinkedHashSet<>(Preferences.getPreferences().getStringSet(
|
||||
"whitelisted_stories_ad",
|
||||
Collections.emptySet()));
|
||||
|
||||
@@ -131,7 +131,7 @@ public class NewsfeedHook {
|
||||
mutableAdsSet.remove(id);
|
||||
}
|
||||
|
||||
getDefaultPrefs().edit().putStringSet("whitelisted_stories_ad", mutableAdsSet).apply();
|
||||
Preferences.getPreferences().edit().putStringSet("whitelisted_stories_ad", mutableAdsSet).apply();
|
||||
}
|
||||
|
||||
public static void adsParams(HashSet<String> hashSet) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
@@ -12,9 +11,7 @@ import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.vk.core.dialogs.actionspopup.ActionsPopup;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
@@ -25,23 +22,18 @@ import com.vk.dto.common.ImageSize;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.attachments.DocumentAttachment;
|
||||
import com.vtosters.lite.attachments.PhotoAttachment;
|
||||
|
||||
import okhttp3.*;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class PhotoViewer {
|
||||
static OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
@@ -203,7 +195,7 @@ public class PhotoViewer {
|
||||
}
|
||||
|
||||
private static int selectedEngine() {
|
||||
return getPreferences().getInt("search_engine", 0);
|
||||
return Preferences.getPreferences().getInt("search_engine", 0);
|
||||
}
|
||||
|
||||
private static void searchPhoto(int i, String url) {
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
|
||||
import android.graphics.*;
|
||||
import com.facebook.drawee.generic.RoundingParams;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class PicRoundingHook {
|
||||
private static final int pref = preferences.getInt("pic_rounding", 0);
|
||||
private static final int pref = Preferences.getPreferences().getInt("pic_rounding", 0);
|
||||
|
||||
public static RoundingParams inject() {
|
||||
if (pref > 0) {
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isRandomProxyEnabled;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isVikaProxyEnabled;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isZaboronaEnabled;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
|
||||
import com.vk.auth.ui.VkAuthTextView;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.ProxySettingsFragment;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
public class ProxyHook {
|
||||
public static void hookAuth(View v) {
|
||||
@@ -77,16 +70,16 @@ public class ProxyHook {
|
||||
.setView(rg)
|
||||
.setPositiveButton(ctx.getString(R.string.vtl_confirm), ((dialog, which) -> { // Применить
|
||||
if (rgZaborona.isChecked()) {
|
||||
edit().putString("proxy", "zaborona").commit();
|
||||
Preferences.getPreferences().edit().putString("proxy", "zaborona").commit();
|
||||
restartApplication();
|
||||
} else if (rgRandomProxy.isChecked()) {
|
||||
edit().putString("proxy", "randomproxy").commit();
|
||||
Preferences.getPreferences().edit().putString("proxy", "randomproxy").commit();
|
||||
restartApplication();
|
||||
} else if (rgVika.isChecked()) {
|
||||
edit().putString("proxy", "vika").commit();
|
||||
Preferences.getPreferences().edit().putString("proxy", "vika").commit();
|
||||
restartApplication();
|
||||
} else {
|
||||
edit().putString("proxy", "noproxy").commit();
|
||||
Preferences.getPreferences().edit().putString("proxy", "noproxy").commit();
|
||||
restartApplication();
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.ui.components.DockBarEditorManager.getInstance;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
import static ru.vtosters.lite.utils.Preferences.superapp;
|
||||
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
|
||||
@@ -35,7 +35,7 @@ public class StartFragmentHook {
|
||||
if (vkme()) {
|
||||
return DialogsFragment.class;
|
||||
}
|
||||
return switch (getPrefsValue("start_values")) {
|
||||
return switch (getString("start_values")) {
|
||||
case "newsfeed" -> milkshake() ? HomeFragment.class : NewsfeedFragment.class;
|
||||
case "messenger" -> DialogsFragment.class;
|
||||
case "groups" -> milkshake() ? CommunitiesCatalogFragment.class : GroupsFragment1.class;
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static android.util.Base64.encodeToString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getBackgroundContent;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getBackgroundPage;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getColorFromAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getHeaderBackground;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getHeaderText;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.hex;
|
||||
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.vk.articles.preload.WebCachePreloader;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.data.ThemeTracker;
|
||||
@@ -27,6 +13,11 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static android.util.Base64.encodeToString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.*;
|
||||
|
||||
public class VKUIHook {
|
||||
public static boolean isLoaded = false;
|
||||
private static String loadedCSS = "";
|
||||
|
||||
@@ -180,7 +180,7 @@ public class LastFMScrobbler {
|
||||
var name = session.getString("name");
|
||||
var key = session.getString("key");
|
||||
|
||||
AndroidUtils.edit()
|
||||
Preferences.getPreferences().edit()
|
||||
.putString("username", name)
|
||||
.putString("sessionKey", key)
|
||||
.putBoolean("lastfm_enabled", true)
|
||||
@@ -190,7 +190,7 @@ public class LastFMScrobbler {
|
||||
}
|
||||
|
||||
public static void logout() {
|
||||
AndroidUtils.edit()
|
||||
Preferences.getPreferences().edit()
|
||||
.remove("username")
|
||||
.remove("sessionKey")
|
||||
.putBoolean("lastfm_enabled", false)
|
||||
@@ -208,14 +208,14 @@ public class LastFMScrobbler {
|
||||
}
|
||||
|
||||
public static boolean isScrobblingEnabled() {
|
||||
return AndroidUtils.getPreferences().getBoolean("lastfm_enabled", false);
|
||||
return Preferences.getPreferences().getBoolean("lastfm_enabled", false);
|
||||
}
|
||||
|
||||
public static String getUserName() {
|
||||
return AndroidUtils.getDefaultPrefs().getString("username", null);
|
||||
return Preferences.getPreferences().getString("username", null);
|
||||
}
|
||||
|
||||
private static String getSessionKey() {
|
||||
return AndroidUtils.getDefaultPrefs().getString("sessionKey", null);
|
||||
return Preferences.getPreferences().getString("sessionKey", null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -93,7 +94,7 @@ public class CatalogJsonInjector {
|
||||
var title = item.optString("title");
|
||||
var id = item.optString("id");
|
||||
var url = item.optString("url");
|
||||
var value = AndroidUtils.getPrefsValue("musicdefcatalog");
|
||||
var value = Preferences.getString("musicdefcatalog");
|
||||
|
||||
Log.d("VKMusic", "title: " + title + " id: " + id + " url: " + url + " value: " + value);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import static ru.vtosters.lite.proxy.api.VikaMobile.getApiHost;
|
||||
import static ru.vtosters.lite.proxy.api.VikaMobile.getOauthHost;
|
||||
import static ru.vtosters.lite.proxy.api.VikaMobile.getStaticHost;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@@ -21,10 +21,11 @@ import ru.vtosters.lite.proxy.http.CustomHttp;
|
||||
import ru.vtosters.lite.proxy.https.CustomHttps;
|
||||
import ru.vtosters.lite.proxy.socks.CustomSocks;
|
||||
import ru.vtosters.lite.proxy.socks.Zaborona;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class ProxyUtils {
|
||||
public static String getApi() {
|
||||
var proxyapi = getPrefsValue("proxyapi");
|
||||
var proxyapi = Preferences.getString("proxyapi");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
proxyapi = getApiHost();
|
||||
@@ -38,7 +39,7 @@ public class ProxyUtils {
|
||||
}
|
||||
|
||||
public static String getOauth() {
|
||||
var oauth = getPrefsValue("proxyoauth");
|
||||
var oauth = Preferences.getString("proxyoauth");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
oauth = getOauthHost();
|
||||
@@ -52,7 +53,7 @@ public class ProxyUtils {
|
||||
}
|
||||
|
||||
public static String getStatic() {
|
||||
var staticapi = getPrefsValue("proxystatic");
|
||||
var staticapi = Preferences.getString("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
staticapi = getStaticHost();
|
||||
@@ -70,19 +71,19 @@ public class ProxyUtils {
|
||||
}
|
||||
|
||||
public static Boolean isZaboronaEnabled() {
|
||||
return getPrefsValue("proxy").equals("zaborona");
|
||||
return Preferences.getString("proxy").equals("zaborona");
|
||||
}
|
||||
|
||||
public static Boolean isRandomProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("randomproxy");
|
||||
return Preferences.getString("proxy").equals("randomproxy");
|
||||
}
|
||||
|
||||
public static Boolean isApiProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("apiproxy");
|
||||
return Preferences.getString("proxy").equals("apiproxy");
|
||||
}
|
||||
|
||||
public static Boolean isVikaProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("vika");
|
||||
return Preferences.getString("proxy").equals("vika");
|
||||
}
|
||||
|
||||
public static void forceProxyApplying() {
|
||||
@@ -134,7 +135,7 @@ public class ProxyUtils {
|
||||
|
||||
public static void setProxy() throws IOException {
|
||||
if (!isAnyProxyEnabled()) return;
|
||||
switch (getPrefsValue("proxy")) {
|
||||
switch (Preferences.getString("proxy")) {
|
||||
case "zaborona" -> Zaborona.loadProxy();
|
||||
case "randomproxy" -> RandomProxy.loadProxy();
|
||||
case "socks" -> CustomSocks.loadProxy();
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package ru.vtosters.lite.proxy;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.resetProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.vtosters.lite.proxy.socks.Hookzof;
|
||||
import ru.vtosters.lite.proxy.socks.Jetkai;
|
||||
import ru.vtosters.lite.proxy.socks.Roosterkid;
|
||||
import ru.vtosters.lite.proxy.socks.TheSpeedX;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.resetProxy;
|
||||
|
||||
public class RandomProxy {
|
||||
public static String type = preferences.getString("random_type", "none");
|
||||
public static String host = preferences.getString("random_host", "");
|
||||
public static String type = Preferences.getPreferences().getString("random_type", "none");
|
||||
public static String host = Preferences.getPreferences().getString("random_host", "");
|
||||
public static boolean showProxyResult = false;
|
||||
|
||||
public static void loadProxy() throws IOException {
|
||||
@@ -40,13 +38,13 @@ public class RandomProxy {
|
||||
}
|
||||
|
||||
public static void setupNewProxy() throws IOException {
|
||||
edit().putString("random_type", "none").putString("random_host", "").commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "none").putString("random_host", "").commit();
|
||||
|
||||
resetProxy();
|
||||
|
||||
showProxyResult = true;
|
||||
getProxy();
|
||||
edit().putString("proxy", "randomproxy").commit();
|
||||
Preferences.getPreferences().edit().putString("proxy", "randomproxy").commit();
|
||||
}
|
||||
|
||||
public static boolean getProxy() throws IOException {
|
||||
|
||||
@@ -2,7 +2,7 @@ package ru.vtosters.lite.proxy.api;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isAnyProxyEnabled;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isVikaProxyEnabled;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -12,9 +12,9 @@ public class ApiProxy {
|
||||
var oauth = "oauth.vk.com";
|
||||
var vkstatic = "static.vk.com";
|
||||
|
||||
var proxyapi = getPrefsValue("proxyapi");
|
||||
var proxyoauth = getPrefsValue("proxyoauth");
|
||||
var proxystatic = getPrefsValue("proxystatic");
|
||||
var proxyapi = getString("proxyapi");
|
||||
var proxyoauth = getString("proxyoauth");
|
||||
var proxystatic = getString("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
proxyapi = VikaMobile.getApiHost();
|
||||
@@ -47,7 +47,7 @@ public class ApiProxy {
|
||||
}
|
||||
|
||||
public static String staticFix(String str) {
|
||||
var string = getPrefsValue("proxystatic");
|
||||
var string = getString("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
string = VikaMobile.getStaticHost();
|
||||
@@ -61,7 +61,7 @@ public class ApiProxy {
|
||||
}
|
||||
|
||||
public static String getAwayPhpCom() {
|
||||
var proxyapi = getPrefsValue("proxyapi");
|
||||
var proxyapi = getString("proxyapi");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
proxyapi = VikaMobile.getApiHost();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.proxy.http;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class CustomHttp {
|
||||
public static void loadProxy() {
|
||||
@@ -13,22 +13,22 @@ public class CustomHttp {
|
||||
}
|
||||
|
||||
private static String proxyHostHTTP() {
|
||||
var string = getPrefsValue("proxyHostHTTP");
|
||||
var string = getString("proxyHostHTTP");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortHTTP() {
|
||||
var string = getPrefsValue("proxyPortHTTP");
|
||||
var string = getString("proxyPortHTTP");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
private static String proxyUserHTTP() {
|
||||
var string = getPrefsValue("proxyUserHTTP");
|
||||
var string = getString("proxyUserHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
private static String proxyPassHTTP() {
|
||||
var string = getPrefsValue("proxyPassHTTP");
|
||||
var string = getString("proxyPassHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.http;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Http";
|
||||
@@ -41,7 +41,7 @@ public class Jetkai {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("http.proxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("http.proxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.http;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class TheSpeedX {
|
||||
private static final String TAG = "TheSpeedX_Http";
|
||||
@@ -40,7 +40,7 @@ public class TheSpeedX {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("http.proxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("http.proxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.proxy.https;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class CustomHttps {
|
||||
public static void loadProxy() {
|
||||
@@ -13,22 +13,22 @@ public class CustomHttps {
|
||||
}
|
||||
|
||||
private static String proxyHostHTTPS() {
|
||||
var string = getPrefsValue("proxyHostHTTPS");
|
||||
var string = getString("proxyHostHTTPS");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortHTTPS() {
|
||||
var string = getPrefsValue("proxyPortHTTPS");
|
||||
var string = getString("proxyPortHTTPS");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
private static String proxyUserHTTPS() {
|
||||
var string = getPrefsValue("proxyUserHTTPS");
|
||||
var string = getString("proxyUserHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
private static String proxyPassHTTPS() {
|
||||
String string = getPrefsValue("proxyPassHTTPS");
|
||||
String string = getString("proxyPassHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.https;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Https";
|
||||
@@ -40,7 +40,7 @@ public class Jetkai {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("https.proxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("https.proxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.https;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Roosterkid {
|
||||
private static final String TAG = "Roosterkid_Https";
|
||||
@@ -40,7 +40,7 @@ public class Roosterkid {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("https.proxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("https.proxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class CustomSocks {
|
||||
public static void loadProxy() {
|
||||
@@ -11,12 +11,12 @@ public class CustomSocks {
|
||||
}
|
||||
|
||||
private static String proxyHostSocks() {
|
||||
var string = getPrefsValue("proxyHostSocks");
|
||||
var string = getString("proxyHostSocks");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortSocks() {
|
||||
var string = getPrefsValue("proxyPortSocks");
|
||||
var string = getString("proxyPortSocks");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.socks;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Hookzof {
|
||||
private static final String TAG = "Hookzof_Socks";
|
||||
@@ -40,7 +40,7 @@ public class Hookzof {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("socksProxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.socks;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Socks";
|
||||
@@ -40,7 +40,7 @@ public class Jetkai {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("socksProxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.socks;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class Roosterkid {
|
||||
private static final String TAG = "Roosterkid_Socks";
|
||||
@@ -40,7 +40,7 @@ public class Roosterkid {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("socksProxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -3,7 +3,6 @@ package ru.vtosters.lite.proxy.socks;
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -14,6 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class TheSpeedX {
|
||||
private static final String TAG = "TheSpeedX_Socks";
|
||||
@@ -40,7 +40,7 @@ public class TheSpeedX {
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
Preferences.getPreferences().edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
System.setProperty("socksProxyPort", proxy.split(":")[1]);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ImBanner {
|
||||
.setMessage(AndroidUtils.getString("custom_links_warning"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.continue_, (dialogInterface, i) -> {
|
||||
Preferences.preferences.edit().putBoolean("linkalert", true).commit();
|
||||
Preferences.getPreferences().edit().putBoolean("linkalert", true).commit();
|
||||
})
|
||||
.setNeutralButton(R.string.cancel, (dialogInterface, i) -> {
|
||||
dialogInterface.cancel();
|
||||
|
||||
@@ -3,7 +3,10 @@ package ru.vtosters.lite.ssfs;
|
||||
import com.vk.core.network.Network;
|
||||
import ru.vtosters.lite.hooks.DateHook;
|
||||
import ru.vtosters.lite.proxy.ProxyUtils;
|
||||
import ru.vtosters.lite.utils.*;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.Base64Utils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class Utils {
|
||||
public static String getVKUILink() {
|
||||
@@ -20,7 +23,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getDomain() {
|
||||
String string = AndroidUtils.getPrefsValue("ssfscustom");
|
||||
String string = Preferences.getString("ssfscustom");
|
||||
|
||||
if (!string.isEmpty()) return string;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package ru.vtosters.lite.themes;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceFile;
|
||||
import com.vtosters.lite.R;
|
||||
@@ -12,6 +13,7 @@ import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
@@ -93,121 +95,126 @@ public class ThemesManager {
|
||||
R.color.darker_blue,
|
||||
R.color.header_blue_opacity40
|
||||
};
|
||||
// modify it if "doNotCompress" in apktool.yml has been edited
|
||||
private final static String[] DO_NOT_COMPRESS = {
|
||||
".png",
|
||||
".jpg",
|
||||
".mp3",
|
||||
"res/raw/keep_cronet_api.xml"
|
||||
};
|
||||
|
||||
private static String baseApkPath;
|
||||
|
||||
private static boolean validated = false;
|
||||
|
||||
// Directories
|
||||
private static File mainDir;
|
||||
private static File binDir;
|
||||
private static File palettesDir;
|
||||
private static File colorSchemesDir;
|
||||
|
||||
// Files
|
||||
|
||||
// Temp archive with resources.arsc and res.zip content for loading resources
|
||||
private static File resTmpZipFile = null;
|
||||
|
||||
// Archive with res and assets folders content
|
||||
private static File resZipFile = null;
|
||||
|
||||
// Resources table file
|
||||
private static File resourcesArscFile = null;
|
||||
// Modified archive with resources.arsc, other resources and assets
|
||||
private static File modApk;
|
||||
|
||||
public static void init(Application app) {
|
||||
try {
|
||||
Log.d("ThemesManager", "init paths");
|
||||
initPaths(app);
|
||||
validateModApk();
|
||||
|
||||
if (!Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && hasBins() && hasTmpArchive()) {
|
||||
if (!Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && canApplyCustomAccent()) {
|
||||
ResourcesLoader.init(app);
|
||||
ResourcesLoader.load(app, resTmpZipFile.getAbsolutePath(), false);
|
||||
ResourcesLoader.load(app, modApk.getAbsolutePath(), false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("ThemesManager", String.valueOf(e));
|
||||
Log.e("ThemesManager", e+"");
|
||||
}
|
||||
}
|
||||
|
||||
// validate modded apk before loading
|
||||
private static void validateModApk()
|
||||
throws IOException {
|
||||
final var apk = new ZipFile(modApk);
|
||||
apk.close();
|
||||
|
||||
validated = true;
|
||||
}
|
||||
|
||||
private static void initPaths(Context context) {
|
||||
baseApkPath = context.getApplicationInfo().sourceDir;
|
||||
baseApkPath = context.getApplicationInfo().publicSourceDir;
|
||||
|
||||
mainDir = new File(context.getFilesDir(), "VTLThemes");
|
||||
if (!mainDir.exists()) mainDir.mkdir();
|
||||
|
||||
binDir = new File(mainDir, "bin");
|
||||
if (!binDir.exists()) binDir.mkdir();
|
||||
colorSchemesDir = new File(mainDir, "color_schemes");
|
||||
if (!colorSchemesDir.exists()) colorSchemesDir.mkdir();
|
||||
|
||||
palettesDir = new File(mainDir, "palettes");
|
||||
if (!palettesDir.exists()) palettesDir.mkdir();
|
||||
|
||||
resZipFile = new File(binDir, "res.zip");
|
||||
|
||||
resourcesArscFile = new File(binDir, "resources.arsc");
|
||||
resTmpZipFile = new File(binDir, "res.tmp.zip");
|
||||
modApk = new File(mainDir, "mod.apk");
|
||||
}
|
||||
|
||||
public static void generateBins()
|
||||
throws IOException {
|
||||
final var apk = new ZipFile(baseApkPath);
|
||||
final var zos = new ZipOutputStream(new FileOutputStream(resZipFile));
|
||||
try(apk;zos) {
|
||||
final var entries = apk.entries();
|
||||
while(entries.hasMoreElements()) {
|
||||
final var entry = entries.nextElement();
|
||||
final var name = entry.getName();
|
||||
if(name.equals("resources.arsc")) {
|
||||
if (!resourcesArscFile.exists()) resourcesArscFile.getParentFile().mkdirs();
|
||||
IOUtils.copy(apk.getInputStream(entry), resourcesArscFile);
|
||||
} else if(name.startsWith("assets/") || name.startsWith("res/")) {
|
||||
zos.putNextEntry(new ZipEntry(name));
|
||||
IOUtils.copy(apk.getInputStream(entry), zos);
|
||||
public static boolean canApplyCustomAccent() {
|
||||
return validated && modApk.exists() && ThemesUtils.getReservedAccent() != Color.TRANSPARENT;
|
||||
}
|
||||
|
||||
public static void generateModApk(int accentColor)
|
||||
throws Throwable {
|
||||
try(
|
||||
final var apk = new ZipFile(baseApkPath)
|
||||
) {
|
||||
final var arscEntry = apk.getEntry("resources.arsc");
|
||||
final var arscBis = new BufferedInputStream(apk.getInputStream(arscEntry));
|
||||
final var arsc = BinaryResourceFile.fromInputStream(arscBis);
|
||||
if(!ArscEditor.changeColors(arsc, ACCENT_COLORS, accentColor))
|
||||
throw new IllegalStateException("Not all colors have been changed");
|
||||
|
||||
try(
|
||||
final var zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(modApk)))
|
||||
) {
|
||||
final var arscBuff = arsc.toByteArray();
|
||||
final var newArscEntry = new ZipEntry("resources.arsc");
|
||||
|
||||
final var crc = new CRC32();
|
||||
crc.update(arscBuff);
|
||||
|
||||
newArscEntry.setSize(arscBuff.length);
|
||||
newArscEntry.setMethod(ZipEntry.STORED);
|
||||
newArscEntry.setCrc(crc.getValue());
|
||||
|
||||
zos.putNextEntry(newArscEntry);
|
||||
zos.write(arscBuff);
|
||||
zos.closeEntry();
|
||||
|
||||
final var entries = apk.entries();
|
||||
while(entries.hasMoreElements()) {
|
||||
final var entry = entries.nextElement();
|
||||
final var name = entry.getName();
|
||||
|
||||
if(!name.startsWith("res/") && !name.startsWith("assets/") || name.equals("resources.arsc")) continue;
|
||||
|
||||
var doNotCompress = false;
|
||||
for(var suffix : DO_NOT_COMPRESS) {
|
||||
if(name.endsWith(suffix)) {
|
||||
doNotCompress = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final var entryBis = new BufferedInputStream(apk.getInputStream(entry));
|
||||
final var newEntry = new ZipEntry(name);
|
||||
|
||||
if(doNotCompress) {
|
||||
newEntry.setMethod(ZipEntry.STORED);
|
||||
newEntry.setSize(entry.getSize());
|
||||
newEntry.setCrc(entry.getCrc());
|
||||
} else newEntry.setMethod(ZipEntry.DEFLATED);
|
||||
|
||||
zos.putNextEntry(newEntry);
|
||||
IOUtils.copy(entryBis, zos);
|
||||
entryBis.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBins() {
|
||||
return resZipFile.exists() && resourcesArscFile.exists();
|
||||
}
|
||||
|
||||
public static boolean hasTmpArchive() {
|
||||
return resTmpZipFile.exists();
|
||||
}
|
||||
|
||||
public static void generateTempResArchive(int accentColor)
|
||||
throws IOException {
|
||||
final var resZip = new ZipFile(resZipFile);
|
||||
final var zos = new ZipOutputStream(new FileOutputStream(resTmpZipFile));
|
||||
try (zos) {
|
||||
final var entries = resZip.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
final var entry = entries.nextElement();
|
||||
final var is = resZip.getInputStream(entry);
|
||||
|
||||
zos.putNextEntry(new ZipEntry(entry.getName()));
|
||||
IOUtils.copy(is, zos);
|
||||
|
||||
is.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
final var arsc = new BinaryResourceFile(IOUtils.readFully(resourcesArscFile));
|
||||
if (!ArscEditor.changeColors(arsc, ACCENT_COLORS, accentColor)) {
|
||||
resZip.close();
|
||||
resTmpZipFile.delete();
|
||||
throw new IOException("Error while generating res.tmp.res");
|
||||
}
|
||||
|
||||
zos.putNextEntry(new ZipEntry("resources.arsc"));
|
||||
IOUtils.copy(new ByteArrayInputStream(arsc.toByteArray()), zos);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteBins() {
|
||||
resZipFile.delete();
|
||||
resourcesArscFile.delete();
|
||||
}
|
||||
|
||||
public static void deleteTmpArchive() {
|
||||
resTmpZipFile.delete();
|
||||
public static void deleteModification() {
|
||||
modApk.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.translators;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
import static ru.vtosters.lite.utils.Preferences.getPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.collection.LruCache;
|
||||
@@ -8,6 +8,7 @@ import androidx.collection.LruCache;
|
||||
import java.util.Locale;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public abstract class BaseTranslator {
|
||||
|
||||
@@ -22,7 +23,7 @@ public abstract class BaseTranslator {
|
||||
};
|
||||
|
||||
public static String getToLanguage() {
|
||||
var lang = preferences.getString("lang_target", "system");
|
||||
var lang = getPreferences().getString("lang_target", "system");
|
||||
var systemLang = Locale.getDefault().getLanguage();
|
||||
|
||||
if (lang.isEmpty() || lang.equals(systemLang) || lang.equals("system"))
|
||||
@@ -32,7 +33,7 @@ public abstract class BaseTranslator {
|
||||
}
|
||||
|
||||
public static BaseTranslator getInstance() {
|
||||
return switch (AndroidUtils.getPreferences().getInt("translator", 0)) {
|
||||
return switch (Preferences.getPreferences().getInt("translator", 0)) {
|
||||
case YANDEX -> YandexTranslator.getInstance();
|
||||
case GOOGLE -> GoogleTranslator.getInstance();
|
||||
case DEEPL -> DeepLTranslator.getInstance();
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.vtosters.lite.general.fragments.GamesFragment;
|
||||
import com.vtosters.lite.general.fragments.PhotosFragment;
|
||||
import ru.vtosters.lite.ui.items.DockBarTab;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -33,7 +34,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class DockBarEditorManager {
|
||||
@@ -110,7 +110,7 @@ public class DockBarEditorManager {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
AndroidUtils.getPreferences()
|
||||
Preferences.getPreferences()
|
||||
.edit()
|
||||
.putString("dockbar_tabs", "tab_news,tab_superapps,tab_messages,tab_friends,tab_profile")
|
||||
.commit();
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package ru.vtosters.lite.ui.components;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class FragAnimationKit {
|
||||
|
||||
// Q
|
||||
@@ -33,8 +31,8 @@ public class FragAnimationKit {
|
||||
private static final int SSTactCloseExit = resources.getIdentifier("task_close_exit", "anim", "android");
|
||||
|
||||
public static void setAnimations(FragmentTransaction transaction) {
|
||||
if (transaction != null && !getPrefsValue("anim_rtrn_type").equals("noanim")) {
|
||||
switch (getPrefsValue("anim_rtrn_type")) {
|
||||
if (transaction != null && !getString("anim_rtrn_type").equals("noanim")) {
|
||||
switch (getString("anim_rtrn_type")) {
|
||||
case "q" -> transaction.setCustomAnimations(
|
||||
actOpenEnter,
|
||||
actOpenExit,
|
||||
|
||||
@@ -2,11 +2,11 @@ package ru.vtosters.lite.ui.components;
|
||||
|
||||
import static ru.vtosters.lite.ui.vkui.VBListBuilder.VBListItem;
|
||||
import static ru.vtosters.lite.ui.vkui.VBListBuilder.buildListOf;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.vk.core.preference.Preference;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -14,12 +14,13 @@ import java.util.Collections;
|
||||
|
||||
import ru.vtosters.lite.ui.vkui.VBottomSheetBuilder;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class NewsfeedListManager {
|
||||
|
||||
public static void callEditorPopup(Activity activity) {
|
||||
var selectedItems = getDefaultPrefs().getString("news_feed_selected_items", "");
|
||||
var filtersSet = getDefaultPrefs().getStringSet("news_feed_items_set", Collections.emptySet());
|
||||
var selectedItems = Preferences.getString("news_feed_selected_items");
|
||||
var filtersSet = Preferences.getPreferences().getStringSet("news_feed_items_set", Collections.emptySet());
|
||||
var list = new ArrayList<VBListItem>(filtersSet.size());
|
||||
|
||||
if (filtersSet.isEmpty()) {
|
||||
@@ -44,7 +45,8 @@ public class NewsfeedListManager {
|
||||
for (VBListItem item : list)
|
||||
if (item.checked)
|
||||
newSelectedItems += item.id + ",";
|
||||
getDefaultPrefs().edit()
|
||||
Preferences.getPreferences()
|
||||
.edit()
|
||||
.putString("news_feed_selected_items", newSelectedItems)
|
||||
.apply();
|
||||
sendToast(activity.getString(R.string.newsfeed_list_update_feed_to_work));
|
||||
@@ -54,7 +56,8 @@ public class NewsfeedListManager {
|
||||
}
|
||||
|
||||
public static void resetHideItems() {
|
||||
getDefaultPrefs().edit()
|
||||
Preferences.getPreferences()
|
||||
.edit()
|
||||
.remove("news_feed_selected_items")
|
||||
.remove("news_feed_items_set")
|
||||
.apply();
|
||||
|
||||
@@ -4,14 +4,13 @@ import android.os.Build;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.ui.items.SuperAppItem;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
|
||||
public class SuperAppEditorManager {
|
||||
|
||||
private static SuperAppEditorManager sInstance;
|
||||
@@ -29,7 +28,7 @@ public class SuperAppEditorManager {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var tmp = getPreferences().getString("superapp_items", "menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run");
|
||||
var tmp = Preferences.getPreferences().getString("superapp_items", "menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run");
|
||||
var selectedTags = !tmp.isEmpty() ? tmp.split(",") : new String[0];
|
||||
parseSelectedItems(selectedTags);
|
||||
}
|
||||
@@ -49,7 +48,7 @@ public class SuperAppEditorManager {
|
||||
public void save() {
|
||||
if (mSelectedItems.size() > 0)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
getPreferences().edit().putString("superapp_items", mSelectedItems.stream()
|
||||
Preferences.getPreferences().edit().putString("superapp_items", mSelectedItems.stream()
|
||||
.map(item -> item.type)
|
||||
.collect(Collectors.joining(",")))
|
||||
.commit();
|
||||
@@ -59,14 +58,14 @@ public class SuperAppEditorManager {
|
||||
sb.append(item.type);
|
||||
sb.append(",");
|
||||
}
|
||||
getPreferences().edit().putString("superapp_items", sb.toString()).commit();
|
||||
Preferences.getPreferences().edit().putString("superapp_items", sb.toString()).commit();
|
||||
}
|
||||
else
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
AndroidUtils.getPreferences()
|
||||
Preferences.getPreferences()
|
||||
.edit()
|
||||
.putString("superapp_items", "menu,miniapps,vkpay_slim,greeting,promo,holiday,informer,event,weather,sport,games,food,music,vk_run")
|
||||
.commit();
|
||||
|
||||
@@ -7,12 +7,9 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class DisableBattery {
|
||||
@@ -33,7 +30,7 @@ public class DisableBattery {
|
||||
activity.startActivity(intent);
|
||||
})
|
||||
.setNeutralButton(R.string.batteryissuebtn2,
|
||||
(dialogInterface, i) -> AndroidUtils.edit().putBoolean("showDoze", false).apply()
|
||||
(dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean("showDoze", false).apply()
|
||||
)
|
||||
.show();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.GmsUtils.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.InstallGMSFragment;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.utils.GmsUtils.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class InstallGMS {
|
||||
public static void alert(final Activity activity) {
|
||||
@@ -22,10 +18,10 @@ public class InstallGMS {
|
||||
.setMessage(activity.getString(R.string.gmsissuesumm))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(activity.getString(R.string.gmsissuebtn1), (
|
||||
dialogInterface, i) -> edit().putBoolean("showAlertGms", false).apply()
|
||||
dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean("showAlertGms", false).apply()
|
||||
)
|
||||
.setNeutralButton(activity.getString(R.string.gmsissuebtn2), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("showAlertGms", false).apply();
|
||||
NavigatorUtils.switchFragment(activity, InstallGMSFragment.class);
|
||||
})
|
||||
.show();
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
|
||||
public class RoundingSeekbarDialog {
|
||||
public static void dialog(Context context) {
|
||||
@@ -20,7 +17,7 @@ public class RoundingSeekbarDialog {
|
||||
SeekBar seek = new SeekBar(context);
|
||||
seek.setMax(10);
|
||||
seek.setKeyProgressIncrement(0);
|
||||
seek.setProgress(getPreferences().getInt("pic_rounding", 0));
|
||||
seek.setProgress(Preferences.getPreferences().getInt("pic_rounding", 0));
|
||||
seek.setPadding(dp2px(16f), dp2px(16f), dp2px(16f), dp2px(16f));
|
||||
|
||||
mContainer.addView(seek, LayoutUtils.createLinear(-1, -2));
|
||||
@@ -32,7 +29,7 @@ public class RoundingSeekbarDialog {
|
||||
.setNegativeButton(context.getString(R.string.cancel), null)
|
||||
.setView(mContainer)
|
||||
.setPositiveButton(context.getString(R.string.vtl_confirm), (dialog, which) -> {
|
||||
edit().putInt("pic_rounding", seek.getProgress()).commit();
|
||||
Preferences.getPreferences().edit().putInt("pic_rounding", seek.getProgress()).commit();
|
||||
restartApplicationWithTimer();
|
||||
})
|
||||
.show();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static android.content.ContentValues.TAG;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.NetworkUtils.isNetworkIsSlow;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
@@ -24,6 +23,7 @@ import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class ServerDialog {
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
@@ -101,9 +101,9 @@ public class ServerDialog {
|
||||
.setMessage(message)
|
||||
.setCancelable(cancelable)
|
||||
.setPositiveButton(positiveButton,
|
||||
(dialogInterface, i) -> edit().putBoolean(key, false).apply())
|
||||
(dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean(key, false).apply())
|
||||
.setNeutralButton(neutralButton, (dialogInterface, i) -> {
|
||||
edit().putBoolean(key, false).apply();
|
||||
Preferences.getPreferences().edit().putBoolean(key, false).apply();
|
||||
var intent = new Intent(Intent.ACTION_VIEW)
|
||||
.setData(Uri.parse(link));
|
||||
activity.startActivity(intent);
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class Start {
|
||||
@@ -23,11 +23,11 @@ public class Start {
|
||||
.setMessage(getWelcome())
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.startbtn2,
|
||||
(dialogInterface, i) -> edit().putBoolean("showAlert", false).apply()
|
||||
(dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean("showAlert", false).apply()
|
||||
)
|
||||
.setNeutralButton(R.string.startbtn1,
|
||||
(dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlert", false).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("showAlert", false).apply();
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://t.me/vtosters")));
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.hooks.VKUIHook;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
|
||||
|
||||
public class ThemeChanging {
|
||||
public static void changeTheme(Activity activity, float[] f) {
|
||||
if (Preferences.systemtheme()) {
|
||||
@@ -20,7 +17,7 @@ public class ThemeChanging {
|
||||
.setMessage(R.string.system_theme_warning)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.proxy_disable, (dialogInterface, i) -> { // Отключить
|
||||
edit().putString("currsystemtheme", !isDarkTheme() ? "dark" : "light").commit();
|
||||
Preferences.getPreferences().edit().putString("currsystemtheme", !isDarkTheme() ? "dark" : "light").commit();
|
||||
VKThemeHelper.b(activity, f);
|
||||
VKUIHook.clearWebCache();
|
||||
})
|
||||
@@ -28,7 +25,7 @@ public class ThemeChanging {
|
||||
.show();
|
||||
} else {
|
||||
VKThemeHelper.b(activity, f);
|
||||
edit().putString("currsystemtheme", isDarkTheme() ? "dark" : "light").commit();
|
||||
Preferences.getPreferences().edit().putString("currsystemtheme", isDarkTheme() ? "dark" : "light").commit();
|
||||
VKUIHook.clearWebCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.ui.fragments.VKUIwrapper;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isAnyProxyEnabled;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.VKUIwrapper;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
|
||||
public class VKIDProtection {
|
||||
public static void alert(final Activity activity) {
|
||||
if (!getBoolValue("showAlertVkId", true)) return;
|
||||
@@ -23,9 +19,9 @@ public class VKIDProtection {
|
||||
.setMessage(R.string.vkidsumm)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.startbtn2,
|
||||
(dialogInterface, i) -> edit().putBoolean("showAlertVkId", false).apply())
|
||||
(dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean("showAlertVkId", false).apply())
|
||||
.setNeutralButton(R.string.vkiddisable, (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertVkId", false).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("showAlertVkId", false).apply();
|
||||
VKUIwrapper.setLink(
|
||||
isAnyProxyEnabled()
|
||||
? "https://id.vk.com/account"
|
||||
|
||||
@@ -43,9 +43,9 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("spamfilters").setSummary(count(getPrefsValue("spamfilters")));
|
||||
findPreference("sourcenamefilter").setSummary(count(getPrefsValue("sourcenamefilter")));
|
||||
findPreference("linkfilter").setSummary(count(getPrefsValue("linkfilter")));
|
||||
findPreference("spamfilters").setSummary(count(Preferences.getString("spamfilters")));
|
||||
findPreference("sourcenamefilter").setSummary(count(Preferences.getString("sourcenamefilter")));
|
||||
findPreference("linkfilter").setSummary(count(Preferences.getString("linkfilter")));
|
||||
|
||||
findPreference("spamfilters").setOnPreferenceClickListener(preference -> {
|
||||
NewsFeedFiltersUtils.setupFilters();
|
||||
@@ -86,7 +86,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
var str = getDefaultPrefs().getString("news_feed_selected_items", "");
|
||||
var str = Preferences.getPreferences().getString("news_feed_selected_items", "");
|
||||
findPreference("newsfeedlistmanager").setSummary(
|
||||
String.format(requireContext().getString(R.string.feed_hidden), (!TextUtils.isEmpty(str) ? str.split(",").length : 0))
|
||||
);
|
||||
@@ -96,7 +96,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("feedcache").setVisible(!getPrefsValue("newsupdate").equals("no_update"));
|
||||
findPreference("feedcache").setVisible(!Preferences.getString("newsupdate").equals("no_update"));
|
||||
}
|
||||
|
||||
private String count(String text) {
|
||||
@@ -116,7 +116,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
.setMessage(requireContext().getString(R.string.delete_elements_confirm))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(requireContext().getString(R.string.yes), (dialogInterface, i) -> {
|
||||
edit().remove(key).apply();
|
||||
Preferences.getPreferences().edit().remove(key).apply();
|
||||
sendToast(requireContext().getString(R.string.elements_deleted_success));
|
||||
NewsFeedFiltersUtils.setupFilters();
|
||||
})
|
||||
@@ -126,7 +126,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
private String countSet(String key) {
|
||||
var set = getDefaultPrefs().getStringSet(key, null);
|
||||
var set = Preferences.getPreferences().getStringSet(key, null);
|
||||
StringBuilder str = new StringBuilder();
|
||||
if (set != null) {
|
||||
for (var s : set) {
|
||||
|
||||
@@ -23,8 +23,8 @@ import ru.vtosters.lite.utils.ThemesUtils;
|
||||
public class IconsFragment extends MaterialPreferenceToolbarFragment {
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void callSelectDialog(Context ctx, String appicon) {
|
||||
var defname = Preferences.preferences.getString("appname", "vt");
|
||||
var deficon = Preferences.preferences.getString("selectedicon", "vt");
|
||||
var defname = Preferences.getPreferences().getString("appname", "vt");
|
||||
var deficon = Preferences.getPreferences().getString("selectedicon", "vt");
|
||||
|
||||
RadioGroup rg = new RadioGroup(ctx);
|
||||
|
||||
@@ -60,18 +60,18 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
|
||||
.setView(rg)
|
||||
.setPositiveButton(R.string.vtl_confirm, ((dialog, which) -> {
|
||||
if (rgDefault.isChecked()) {
|
||||
AndroidUtils.edit().putString("appname", "vt").commit();
|
||||
AndroidUtils.edit().putString("selectedicon", appicon).commit();
|
||||
Preferences.getPreferences().edit().putString("appname", "vt").commit();
|
||||
Preferences.getPreferences().edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
IconManager.switchComponent(appicon, "vt");
|
||||
} else if (rgVK.isChecked()) {
|
||||
AndroidUtils.edit().putString("appname", "standard").commit();
|
||||
AndroidUtils.edit().putString("selectedicon", appicon).commit();
|
||||
Preferences.getPreferences().edit().putString("appname", "standard").commit();
|
||||
Preferences.getPreferences().edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
IconManager.switchComponent(appicon, "standard");
|
||||
} else if (rgVKontakte.isChecked()) {
|
||||
AndroidUtils.edit().putString("appname", "vkontakte").commit();
|
||||
AndroidUtils.edit().putString("selectedicon", appicon).commit();
|
||||
Preferences.getPreferences().edit().putString("appname", "vkontakte").commit();
|
||||
Preferences.getPreferences().edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
IconManager.switchComponent(appicon, "vkontakte");
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
|
||||
public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
@@ -45,7 +45,7 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
findPreference("dateformat").setOnPreferenceChangeListener((preference, o) -> {
|
||||
edit().putString("dateformat", o.toString()).commit();
|
||||
Preferences.getPreferences().edit().putString("dateformat", o.toString()).commit();
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
});
|
||||
@@ -78,10 +78,10 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("anim_rtrn_type").setVisible(false);
|
||||
}
|
||||
|
||||
if (getPreferences().getInt("pic_rounding", 0) == 0) {
|
||||
if (Preferences.getPreferences().getInt("pic_rounding", 0) == 0) {
|
||||
findPreference("customrounding").setSummary(requireContext().getString(R.string.disabled));
|
||||
} else {
|
||||
findPreference("customrounding").setSummary(String.format(requireContext().getString(R.string.rounding_size), getPreferences().getInt("pic_rounding", 0)));
|
||||
findPreference("customrounding").setSummary(String.format(requireContext().getString(R.string.rounding_size), Preferences.getPreferences().getInt("pic_rounding", 0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import ru.vtosters.lite.music.LastFMScrobbler;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -152,11 +153,11 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
);
|
||||
|
||||
var adapter = new ImagineArrayAdapter(requireContext(), items);
|
||||
adapter.setSelected(getPreferences().getInt("search_engine", 0));
|
||||
adapter.setSelected(Preferences.getPreferences().getInt("search_engine", 0));
|
||||
|
||||
new VkAlertDialog.Builder(getActivity())
|
||||
.setAdapter(adapter, (dialog, which) -> {
|
||||
getPreferences().edit().putInt("search_engine", which).apply();
|
||||
Preferences.getPreferences().edit().putInt("search_engine", which).apply();
|
||||
dialog.cancel();
|
||||
})
|
||||
.show();
|
||||
|
||||
@@ -7,10 +7,10 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
@@ -47,11 +47,11 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
);
|
||||
|
||||
var adapter = new ImagineArrayAdapter(requireContext(), items);
|
||||
adapter.setSelected(getPreferences().getInt("translator", 0));
|
||||
adapter.setSelected(Preferences.getPreferences().getInt("translator", 0));
|
||||
|
||||
new VkAlertDialog.Builder(getActivity())
|
||||
.setAdapter(adapter, (dialog, which) -> {
|
||||
getPreferences().edit().putInt("translator", which).apply();
|
||||
Preferences.getPreferences().edit().putInt("translator", which).apply();
|
||||
dialog.cancel();
|
||||
})
|
||||
.show();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
if (requestCode == VK_ADMIN_TOKEN_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
String token = data.getStringExtra("token");
|
||||
AndroidUtils.getPreferences().edit().putString("vk_admin_token", token).apply();
|
||||
Preferences.getPreferences().edit().putString("vk_admin_token", token).apply();
|
||||
Toast.makeText(getContext(), requireContext().getString(R.string.token_saved), LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
var pref = getDefaultPrefs().getString("autoclearcache", "Default");
|
||||
var pref = Preferences.getPreferences().getString("autoclearcache", "Default");
|
||||
switch (pref) {
|
||||
case "Default" ->
|
||||
findPreference("autoclearcache").setSummary(requireContext().getString(R.string.cache_disabled));
|
||||
@@ -198,7 +198,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
var vkAdminTokenPref = findPreference("vk_admin_token");
|
||||
vkAdminTokenPref.setVisible(AndroidUtils.getDefaultPrefs().getBoolean("new_music_downloading_way", false));
|
||||
vkAdminTokenPref.setVisible(Preferences.getPreferences().getBoolean("new_music_downloading_way", false));
|
||||
if (vkAdminTokenPref.isVisible()) {
|
||||
vkAdminTokenPref.setOnPreferenceClickListener(preference -> {
|
||||
startActivityForResult(new Intent(getContext(), VKAdminTokenActivity.class), VK_ADMIN_TOKEN_REQUEST_CODE);
|
||||
@@ -212,7 +212,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
private void cacheAutoCleanDialog() {
|
||||
String[] cacheText = {null, "100 MB", "500 MB", "1 GB", "2 GB", "5 GB"};
|
||||
|
||||
var val = getDefaultPrefs().getInt("autoclearcache_size", 0);
|
||||
var val = Preferences.getPreferences().getInt("autoclearcache_size", 0);
|
||||
RadioGroup rg = new RadioGroup(getContext());
|
||||
|
||||
rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0);
|
||||
@@ -239,7 +239,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
.setPositiveButton(requireContext().getString(R.string.save), (dialog, which) -> {
|
||||
var sizes = new String[]{"Default", "100mb", "500mb", "1gb", "2gb", "5gb"};
|
||||
var id = rg.getCheckedRadioButtonId();
|
||||
getDefaultPrefs().edit()
|
||||
Preferences.getPreferences().edit()
|
||||
.putInt("autoclearcache_size", id)
|
||||
.putString("autoclearcache", sizes[id])
|
||||
.apply();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -19,22 +20,15 @@ import ru.vtosters.lite.ui.views.rarepebble.ColorPickerView;
|
||||
import ru.vtosters.lite.ui.wallpapers.WallpaperMenuFragment;
|
||||
import ru.vtosters.lite.utils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.recolorDrawable;
|
||||
|
||||
public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
private VKProgressDialog mProgressDialog;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
mProgressDialog = new VKProgressDialog(requireContext());
|
||||
mProgressDialog.setCancelable(false);
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences_themes);
|
||||
initPreferences();
|
||||
}
|
||||
@@ -57,11 +51,12 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
var invalidateThemeCache = findPreference("invalidate_theme_cache");
|
||||
invalidateThemeCache.setOnPreferenceClickListener(preference -> {
|
||||
ThemesManager.deleteBins();
|
||||
setAccentColor(ThemesUtils.getReservedAccent(), true);
|
||||
return true;
|
||||
});
|
||||
if(ThemesUtils.getReservedAccent() != Color.TRANSPARENT)
|
||||
invalidateThemeCache.setOnPreferenceClickListener(preference -> {
|
||||
setAccentColor(ThemesUtils.getReservedAccent());
|
||||
return true;
|
||||
});
|
||||
else invalidateThemeCache.setVisible(false);
|
||||
|
||||
var navBarPreference = findPreference("navbar");
|
||||
navBarPreference.setOnPreferenceClickListener(preference -> {
|
||||
@@ -163,8 +158,9 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.reset, (dialog, which) -> {
|
||||
ThemesManager.deleteTmpArchive();
|
||||
LifecycleUtils.restartApplicationWithTimer();
|
||||
ThemesManager.deleteModification();
|
||||
ThemesUtils.reserveAccentColor(Color.TRANSPARENT, false);
|
||||
restart();
|
||||
})
|
||||
.setPositiveButton(R.string.cancel, null)
|
||||
.show();
|
||||
@@ -184,7 +180,7 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
alertDialog.setButton(
|
||||
DialogInterface.BUTTON_POSITIVE,
|
||||
requireContext().getString(R.string.select),
|
||||
(dialog, which) -> setAccentColor(colorPickerView.getColor(), false)
|
||||
(dialog, which) -> setAccentColor(colorPickerView.getColor())
|
||||
);
|
||||
alertDialog.setView(colorPickerView);
|
||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
|
||||
@@ -201,56 +197,37 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
.setTitle(AndroidUtils.getString("select_palette"))
|
||||
.setItems(titles, (dialog, which) ->
|
||||
PalettesBottomSheetDialog.create(requireActivity(), manager.getPalette(which),
|
||||
(adapter, vtlcolor) -> setAccentColor(vtlcolor.color, false))
|
||||
(adapter, vtlcolor) -> setAccentColor(vtlcolor.color))
|
||||
)
|
||||
.setPositiveButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
void setAccentColor(int color, boolean invalidate) {
|
||||
String message;
|
||||
Runnable task;
|
||||
if(!ThemesManager.hasBins()) {
|
||||
message = invalidate ? "Инвалидация кэша" : "Генерация файлов...";
|
||||
task = () -> {
|
||||
try {
|
||||
ThemesManager.generateBins();
|
||||
requireActivity().runOnUiThread(() -> setAccentColor(color, invalidate));
|
||||
} catch(IOException e) {
|
||||
Log.e("ThemesFragment", e+"");
|
||||
ThemesManager.deleteBins();
|
||||
requireActivity().runOnUiThread(() -> showErrorDialog("Ошибка при " + (invalidate ? "инвалидации кэша" : "генерации файлов")));
|
||||
}
|
||||
};
|
||||
} else {
|
||||
message = invalidate ? "Инвалидация кэша" : "Применение акцента...";
|
||||
task = () -> {
|
||||
try {
|
||||
if(!invalidate) ThemesUtils.reserveAccentColor(color);
|
||||
ThemesManager.generateTempResArchive(color);
|
||||
requireActivity().runOnUiThread(this::restart);
|
||||
} catch(IOException e) {
|
||||
Log.e("ThemesFragment", e+"");
|
||||
ThemesManager.deleteTmpArchive();
|
||||
requireActivity().runOnUiThread(() -> showErrorDialog("Ошибка при " + (invalidate ? "инвалидации кэша" : "применении акцента")));
|
||||
}
|
||||
};
|
||||
}
|
||||
void setAccentColor(int color) {
|
||||
final VKProgressDialog dialog = new VKProgressDialog(requireContext());
|
||||
dialog.setCancelable(false);
|
||||
dialog.setMessage("Применение акцента...");
|
||||
dialog.show();
|
||||
|
||||
mProgressDialog.setMessage(message);
|
||||
mProgressDialog.show();
|
||||
|
||||
VTExecutors.getIoExecutor().execute(task);
|
||||
}
|
||||
|
||||
void showErrorDialog(String msg) {
|
||||
mProgressDialog.dismiss();
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle("Ошибка")
|
||||
.setMessage(msg)
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
VTExecutors.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
ThemesUtils.reserveAccentColor(color, true);
|
||||
ThemesManager.generateModApk(color);
|
||||
requireActivity().runOnUiThread(this::restart);
|
||||
} catch(Throwable e) {
|
||||
Log.e("ThemesFragment", e+"");
|
||||
ThemesManager.deleteModification();
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
dialog.dismiss();
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle("Ошибка")
|
||||
.setMessage("Ошибка при применении акцента:\n" + e)
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void restart() {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
}
|
||||
|
||||
public static String getProxysumm() {
|
||||
var type = AndroidUtils.getPrefsValue("proxy");
|
||||
var type = Preferences.getString("proxy");
|
||||
|
||||
if(type.equals("noproxy") || type.isEmpty())
|
||||
type = AndroidUtils.getString(R.string.vtlsettdisabled);
|
||||
@@ -63,7 +63,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
public static String getThemesumm() {
|
||||
String[] themeTypeName = AndroidUtils.getArray("theme_type_name");
|
||||
|
||||
return AndroidUtils.getString("current_theme") + ": " + switch (AndroidUtils.getPrefsValue("currsystemtheme")) {
|
||||
return AndroidUtils.getString("current_theme") + ": " + switch (Preferences.getString("currsystemtheme")) {
|
||||
case "system" -> themeTypeName[0];
|
||||
case "dark" -> themeTypeName[1];
|
||||
case "light" -> themeTypeName[2];
|
||||
@@ -175,7 +175,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
var theme = value.equals("dark") ? ThemesUtils.getDarkTheme() : ThemesUtils.getLightTheme();
|
||||
ThemesUtils.applyTheme(theme);
|
||||
}
|
||||
AndroidUtils.edit().putString("currsystemtheme", value).commit();
|
||||
Preferences.getPreferences().edit().putString("currsystemtheme", value).commit();
|
||||
SystemThemeChangerHook.onThemeChanged(getResources().getConfiguration());
|
||||
return true;
|
||||
});
|
||||
@@ -235,7 +235,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
R.drawable.ic_globe_outline_28,
|
||||
true,
|
||||
(preference, o) -> {
|
||||
AndroidUtils.edit().putBoolean("ssl", (boolean) o).commit();
|
||||
Preferences.getPreferences().edit().putBoolean("ssl", (boolean) o).commit();
|
||||
return true;
|
||||
}
|
||||
);
|
||||
@@ -250,7 +250,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
true,
|
||||
(preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
AndroidUtils.edit().putBoolean("autoupdates", value).commit();
|
||||
Preferences.getPreferences().edit().putBoolean("autoupdates", value).commit();
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,11 +4,11 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
|
||||
enum ImageEffects {
|
||||
Blur(true,
|
||||
@@ -19,7 +19,7 @@ enum ImageEffects {
|
||||
@Override
|
||||
public void applyEffect(ByteBuffer bitmap, int height, int width) {
|
||||
int radius;
|
||||
switch (getPreferences().getString(ImageEffects.Blur.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Blur.toString(), "disabled")) {
|
||||
case "low":
|
||||
radius = 8;
|
||||
break;
|
||||
@@ -37,7 +37,7 @@ enum ImageEffects {
|
||||
|
||||
@Override
|
||||
public String getSummary() {
|
||||
switch (getPreferences().getString(ImageEffects.Blur.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Blur.toString(), "disabled")) {
|
||||
case "low":
|
||||
return AndroidUtils.getString(R.string.wallpapers_low);
|
||||
case "med":
|
||||
@@ -56,7 +56,7 @@ enum ImageEffects {
|
||||
@Override
|
||||
public void applyEffect(ByteBuffer bitmap, int height, int width) {
|
||||
var delta = 0;
|
||||
switch (getPreferences().getString(ImageEffects.Dim.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Dim.toString(), "disabled")) {
|
||||
case "dim_black":
|
||||
delta = -50; break;
|
||||
case "dim_white":
|
||||
@@ -69,7 +69,7 @@ enum ImageEffects {
|
||||
|
||||
@Override
|
||||
public String getSummary() {
|
||||
switch (getPreferences().getString(ImageEffects.Dim.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Dim.toString(), "disabled")) {
|
||||
case "dim_black":
|
||||
return AndroidUtils.getString(R.string.wallpapers_dim_black);
|
||||
case "dim_white":
|
||||
@@ -86,7 +86,7 @@ enum ImageEffects {
|
||||
@Override
|
||||
public void applyEffect(ByteBuffer bitmap, int height, int width) {
|
||||
var scale = 0;
|
||||
switch (getPreferences().getString(ImageEffects.Mosaic.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Mosaic.toString(), "disabled")) {
|
||||
case "high":
|
||||
scale = 50; break;
|
||||
case "med":
|
||||
@@ -101,7 +101,7 @@ enum ImageEffects {
|
||||
|
||||
@Override
|
||||
public String getSummary() {
|
||||
switch (getPreferences().getString(ImageEffects.Mosaic.toString(), "disabled")) {
|
||||
switch (Preferences.getPreferences().getString(ImageEffects.Mosaic.toString(), "disabled")) {
|
||||
case "low":
|
||||
return AndroidUtils.getString(R.string.wallpapers_low);
|
||||
case "med":
|
||||
@@ -234,7 +234,7 @@ enum ImageEffects {
|
||||
public abstract void applyEffect(ByteBuffer bitmap, int height, int width);
|
||||
|
||||
protected boolean isApplied() {
|
||||
return getPreferences().getBoolean(this.toString(), false);
|
||||
return Preferences.getPreferences().getBoolean(this.toString(), false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.im.ImEngineProvider;
|
||||
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -19,7 +20,6 @@ import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
|
||||
@@ -119,7 +119,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
);
|
||||
pref.setSummary(it.getSummary());
|
||||
pref.setOnPreferenceChangeListener((preference, o) -> {
|
||||
edit().putString(it.toString(), (String) o).apply();
|
||||
Preferences.getPreferences().edit().putString(it.toString(), (String) o).apply();
|
||||
preference.setSummary(it.getSummary());
|
||||
requestUpdateWallpaper();
|
||||
mWPPreviewPref.redraw();
|
||||
@@ -134,7 +134,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
0,
|
||||
false,
|
||||
(preference, o) -> {
|
||||
edit().putBoolean(it.toString(), (Boolean) o).apply();
|
||||
Preferences.getPreferences().edit().putBoolean(it.toString(), (Boolean) o).apply();
|
||||
requestUpdateWallpaper();
|
||||
mWPPreviewPref.redraw();
|
||||
return true;
|
||||
@@ -151,7 +151,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
true,
|
||||
(preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
edit().putBoolean("compresswp", value).commit();
|
||||
Preferences.getPreferences().edit().putBoolean("compresswp", value).commit();
|
||||
requestUpdateWallpaper();
|
||||
mWPPreviewPref.redraw();
|
||||
return true;
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.VERSIONNAME;
|
||||
import static ru.vtosters.lite.utils.Preferences.devmenu;
|
||||
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class About {
|
||||
public static String getBuildNumber() {
|
||||
return getBuild(getGlobalContext(), "version.properties");
|
||||
@@ -26,7 +22,7 @@ public class About {
|
||||
if (devmenu()) {
|
||||
sendToast(AndroidUtils.getString(R.string.debug_menu_already_activated));
|
||||
} else {
|
||||
edit().putBoolean("devmenu", true).apply();
|
||||
Preferences.getPreferences().edit().putBoolean("devmenu", true).apply();
|
||||
sendToast(AndroidUtils.getString(R.string.debug_menu_activated));
|
||||
}
|
||||
return true;
|
||||
@@ -38,16 +34,14 @@ public class About {
|
||||
}
|
||||
|
||||
public static String getBuild(Context context, String name) {
|
||||
try (
|
||||
Scanner scanner = new Scanner(context.getAssets().open(name))
|
||||
) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.findInLine("VERSION_BUILD=.+");
|
||||
if (line != null)
|
||||
return line.replace("VERSION_BUILD=", "");
|
||||
return "0000000";
|
||||
try {
|
||||
final var scanner = new Scanner(context.getAssets().open(name, AssetManager.ACCESS_BUFFER));
|
||||
while(scanner.hasNextLine()) {
|
||||
final var line = scanner.findInLine("VERSION_BUILD=.+");
|
||||
if(!TextUtils.isEmpty(line))
|
||||
return line.substring(14);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "0000000";
|
||||
|
||||
@@ -32,28 +32,10 @@ import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class AndroidUtils {
|
||||
|
||||
public static SharedPreferences getDefaultPrefs() {
|
||||
if (Preferences.preferences == null)
|
||||
Preferences.preferences = PreferenceManager.getDefaultSharedPreferences(getGlobalContext());
|
||||
return Preferences.preferences;
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getGlobalContext());
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
return Screen.l(getGlobalContext());
|
||||
}
|
||||
|
||||
public static String getPrefsValue(String pref) {
|
||||
return getPreferences().getString(pref, "");
|
||||
} // Get pref value as string
|
||||
|
||||
public static SharedPreferences.Editor edit() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getGlobalContext()).edit();
|
||||
} // Edit SharedPreferences
|
||||
|
||||
@NonNull
|
||||
public static Context getGlobalContext() {
|
||||
try {
|
||||
@@ -176,7 +158,7 @@ public class AndroidUtils {
|
||||
.setMessage(AndroidUtils.getString("app_open_by_default_settings"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(com.vtosters.lite.R.string.social_graph_skip,
|
||||
(dialogInterface, i) -> edit().putBoolean("showUnverifDialog", false).apply()
|
||||
(dialogInterface, i) -> Preferences.getPreferences().edit().putBoolean("showUnverifDialog", false).apply()
|
||||
)
|
||||
.setNeutralButton(com.vtosters.lite.R.string.open_settings,
|
||||
(dialogInterface, i) -> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -73,7 +73,7 @@ public class DeletedMessagesHandler {
|
||||
}
|
||||
|
||||
private static String getPrefixUndelete() {
|
||||
var prefs = getPrefsValue("undeletemsg_prefix_value");
|
||||
var prefs = getString("undeletemsg_prefix_value");
|
||||
|
||||
if (prefs.isEmpty()) {
|
||||
return "\uD83D\uDDD1 ";
|
||||
|
||||
@@ -17,7 +17,7 @@ import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class IOUtils {
|
||||
public static final int BUFFER_SIZE = 0x800;
|
||||
public static final int BUFFER_SIZE = 8192;
|
||||
|
||||
public static byte[] decodeStream(InputStream encIs, String keyURL)
|
||||
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ImageUtils {
|
||||
final int width = bitmap.getWidth();
|
||||
final int height = bitmap.getHeight();
|
||||
final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
int pref = Preferences.preferences.getInt("pic_rounding", 0);
|
||||
int pref = Preferences.getPreferences().getInt("pic_rounding", 0);
|
||||
final Canvas canvas = new Canvas(outputBitmap);
|
||||
|
||||
final Path path = new Path();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.ads;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsgroup;
|
||||
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
|
||||
@@ -41,17 +41,17 @@ public class NewsFeedFiltersUtils {
|
||||
getFilter("shitposting", "IDontWantToReadIt.txt", mFilters);
|
||||
getFilter("cringecopyright", "CopyrightAds.txt", mFiltersLinks);
|
||||
|
||||
var customFilters = getPrefsValue("spamfilters");
|
||||
var customFilters = getString("spamfilters");
|
||||
if (!customFilters.isEmpty()) {
|
||||
mFilters.addAll(Arrays.asList(customFilters.toLowerCase().split(", ")));
|
||||
}
|
||||
|
||||
var sourceNameFilter = getPrefsValue("sourcenamefilter");
|
||||
var sourceNameFilter = getString("sourcenamefilter");
|
||||
if (!sourceNameFilter.isEmpty()) {
|
||||
mFiltersNames.addAll(Arrays.asList(sourceNameFilter.toLowerCase().split(", ")));
|
||||
}
|
||||
|
||||
var linkFilter = getPrefsValue("linkfilter");
|
||||
var linkFilter = getString("linkfilter");
|
||||
if (!linkFilter.isEmpty()) {
|
||||
mFiltersLinks.addAll(Arrays.asList(linkFilter.toLowerCase().split(", ")));
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public class NewsFeedFiltersUtils {
|
||||
}
|
||||
|
||||
public static String getAllFilters() {
|
||||
return getPrefsValue("spamfilters");
|
||||
return getString("spamfilters");
|
||||
}
|
||||
|
||||
public static boolean isBadNews(String text) {
|
||||
|
||||
@@ -1,33 +1,26 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
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.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
|
||||
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.StrictMode;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vtosters.lite.data.Users;
|
||||
import com.vtosters.lite.fragments.SettingsListFragment;
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
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.NewsFeedFiltersUtils.setupFilters;
|
||||
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
|
||||
|
||||
public class Preferences {
|
||||
public static SharedPreferences preferences = getGlobalContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
|
||||
public static String VERSIONNAME = "Beta";
|
||||
|
||||
public static void init(Application application) throws Exception {
|
||||
@@ -41,6 +34,14 @@ public class Preferences {
|
||||
LifecycleUtils.registerActivities(application);
|
||||
} // VK Init
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
return getGlobalContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static String getString(String name) {
|
||||
return getPreferences().getString(name, "");
|
||||
}
|
||||
|
||||
public static void forceOffline() {
|
||||
setupFilters();
|
||||
|
||||
@@ -50,10 +51,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static boolean getBoolValue(String key, Boolean value) {
|
||||
if (preferences == null) {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(getGlobalContext());
|
||||
}
|
||||
return preferences.getBoolean(key, value);
|
||||
return getPreferences().getBoolean(key, value);
|
||||
} // Set bool by default and get value
|
||||
|
||||
public static SharedPreferences getPrefsFromFile(String filename) {
|
||||
@@ -292,12 +290,12 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static boolean isNewBuild() {
|
||||
return !preferences.getString("build_number", About.getBuildNumber())
|
||||
return !getPreferences().getString("build_number", "")
|
||||
.equals(About.getBuildNumber());
|
||||
}
|
||||
|
||||
public static void updateBuildNumber() {
|
||||
preferences.edit().putString("build_number", About.getBuildNumber()).apply();
|
||||
getPreferences().edit().putString("build_number", About.getBuildNumber()).commit();
|
||||
}
|
||||
|
||||
public static boolean isValidSignature() {
|
||||
@@ -322,7 +320,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static long getSizeForDelete() {
|
||||
return switch (getPrefsValue("clearcache")) {
|
||||
return switch (Preferences.getPreferences().getString("clearcache", "")) {
|
||||
case "100mb" -> 104857600L;
|
||||
case "500mb" -> 524288000L;
|
||||
case "1gb" -> 1073741824L;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ThemesUtils {
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static boolean isCustomAccentEnabled() {
|
||||
return ThemesUtils.isMonetTheme() || ThemesManager.hasTmpArchive();
|
||||
return ThemesUtils.isMonetTheme() || ThemesManager.canApplyCustomAccent();
|
||||
}
|
||||
|
||||
public static ColorStateList getAccenedColorStateList() {
|
||||
@@ -104,11 +104,14 @@ public class ThemesUtils {
|
||||
//region Used for migrating accent color to new version
|
||||
|
||||
public static int getReservedAccent() {
|
||||
return AndroidUtils.getPreferences().getInt("reserved_accent_color", getAccentColor());
|
||||
return Preferences.getPreferences().getInt("reserved_accent_color", Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
public static void reserveAccentColor(int accent) {
|
||||
AndroidUtils.getPreferences().edit().putInt("reserved_accent_color", accent).apply();
|
||||
public static void reserveAccentColor(int accent, boolean async) {
|
||||
final var editor = Preferences.getPreferences().edit();
|
||||
editor.putInt("reserved_accent_color", accent);
|
||||
if(async) editor.apply();
|
||||
else editor.commit();
|
||||
}
|
||||
|
||||
//endregion
|
||||
@@ -209,7 +212,7 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static void setCustomAccentColor(int newColor, boolean async) {
|
||||
var editor = AndroidUtils.edit().putInt("accent_color", newColor);
|
||||
var editor = Preferences.getPreferences().edit().putInt("accent_color", newColor);
|
||||
if (async) editor.apply();
|
||||
else editor.commit();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vtosters.lite.R;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getOauth;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class VKMeHandler {
|
||||
public static void getVkMeToken(String username, String password) {
|
||||
makeRequest("https://" +
|
||||
@@ -45,15 +41,15 @@ public class VKMeHandler {
|
||||
}
|
||||
|
||||
public static void removeToken() {
|
||||
edit().remove("vkmetoken").commit();
|
||||
Preferences.getPreferences().edit().remove("vkmetoken").commit();
|
||||
}
|
||||
|
||||
public static String getToken() {
|
||||
return getPrefsValue("vkmetoken");
|
||||
return Preferences.getString("vkmetoken");
|
||||
}
|
||||
|
||||
public static void setToken(String token) {
|
||||
edit().putString("vkmetoken", token).commit();
|
||||
Preferences.getPreferences().edit().putString("vkmetoken", token).commit();
|
||||
}
|
||||
|
||||
public static void setPrivacyStatus(String status) {
|
||||
|
||||
Reference in New Issue
Block a user