some shitcode for saving wp + true compressing + moved to webp format of file
This commit is contained in:
@@ -135,7 +135,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment{
|
||||
public class openofficialsett implements Preference.OnPreferenceClickListener{
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference){
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(NewsfeedSettingsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.removeWallpaper;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
@@ -102,11 +100,11 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
public class openwp implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
// Context context = getContext();
|
||||
// Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
|
||||
// a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// context.startActivity(a2);
|
||||
sendToast("Обои временно недоступны. Следите за новостями на @vtosters в Telegram");
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
// sendToast("Обои временно недоступны. Следите за новостями на @vtosters в Telegram");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
public class openicons implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(IconsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
|
||||
@@ -150,11 +150,11 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
VKAuth.a("logout", false);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
var intent = new Intent(getContext(), MainActivity.class);
|
||||
var intent = new Intent(requireContext(), MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
requireContext().startActivity(intent);
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -185,7 +185,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
if (!isGmsInstalled()) {
|
||||
addPreference(this, "", AndroidUtils.getString("installgms"), "", "ic_about_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(InstallGMSFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -197,7 +197,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
addPreferenceCategory(this, AndroidUtils.getString("sett_debug"));
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("sett_debug"), "", "ic_bug_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(SettingsDebugFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -214,7 +214,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
addPreferenceCategory(this, AndroidUtils.getString("vtsettaccount"));
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vkconnect"), "", "ic_user_circle_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
VKUIwrapper.officalLinks("account");
|
||||
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -223,7 +223,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("privacy_settings"), "", "ic_privacy_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(PrivacyFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -231,7 +231,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("sett_account"), "", "ic_user_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(SettingsAccountFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -240,7 +240,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
if (isVKTester()) {
|
||||
addPreference(this, "", AndroidUtils.getString("bugs"), "", "ic_bug_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
VKUIwrapper.officalLinks("bugs");
|
||||
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -250,7 +250,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtssfs"), ssfs, "ic_link_circle_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
VKUIwrapper.setLink(SSFSUtils.getSSFSLink());
|
||||
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -261,7 +261,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
addPreferenceCategory(this, AndroidUtils.getString("notification_settings"));
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("sett_general"), "", "ic_settings_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(SettingsGeneralFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -269,7 +269,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("blacklist"), "", "ic_users_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(BlacklistFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -277,7 +277,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("sett_notifications"), "", "ic_menu_notification_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(NotificationsSettingsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -286,7 +286,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
if (VKAccountManager.d().isMusicSubs()) {
|
||||
addPreference(this, "", AndroidUtils.getString("subscription_music"), "", "ic_music_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -295,7 +295,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("votes"), "", "ic_coins_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(BalanceFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -306,7 +306,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
if (!vkme()) {
|
||||
addPreference(this, "", AndroidUtils.getString("vtlfeed"), feedsumm, "ic_newsfeed_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(FeedFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -314,7 +314,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("dockbar_editor"), docksumm, "ic_list_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent intent = new Navigator(DockBarEditorFragment.class).b(context);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
@@ -323,7 +323,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
if (milkshake() && superapp()) {
|
||||
addPreference(this, "", AndroidUtils.getString("superapp_editor"), superapp, "ic_services_outline_28", (preference) -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent intent = new Navigator(SuperAppEditorFragment.class).b(context);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
@@ -335,7 +335,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlmedia"), mediasumm, "ic_media_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(MediaFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -343,7 +343,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlmessages"), msgsumm, "ic_message_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(MessagesFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -351,7 +351,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlactivity"), activitysumm, "ic_write_outline_28_new_accent", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(ActivityFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -359,7 +359,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlthemes"), themessumm, "ic_write_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(ThemesFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -367,7 +367,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtltgs"), tgssumm, "ic_telegram_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(StickersFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -375,7 +375,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlinterface"), interfacesumm, "ic_interface_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(InterfaceFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -383,7 +383,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlproxy"), proxysumm, "ic_globe_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(ProxySettingsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -391,7 +391,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtlother"), othersumm, "ic_more_horizontal_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(OtherFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -401,7 +401,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
addPreferenceCategory(this, AndroidUtils.getString("vtsettaboutmod"));
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("menu_about"), about, "ic_about_outline_28", preference -> {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(AboutAppFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
@@ -409,17 +409,17 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("opencommit"), "", "ic_link_outline_28", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
|
||||
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
|
||||
return false;
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("vtfaq"), AndroidUtils.getString("vtfaqsumm"), "ic_help_outline_28", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
|
||||
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
|
||||
return false;
|
||||
});
|
||||
|
||||
addPreference(this, "", AndroidUtils.getString("reportbug"), AndroidUtils.getString("reportbugsumm"), "ic_bug_outline_28", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
|
||||
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@ package ru.vtosters.lite.ui.wallpapers;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
||||
public class ConvolutionMatrix {
|
||||
public class ConvolutionMatrix{
|
||||
public static final int SIZE = 3;
|
||||
|
||||
public double[][] Matrix;
|
||||
public double Factor = 1;
|
||||
public double Offset = 1;
|
||||
|
||||
public ConvolutionMatrix(int size) {
|
||||
public ConvolutionMatrix(int size){
|
||||
Matrix = new double[size][size];
|
||||
}
|
||||
|
||||
public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix) {
|
||||
public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix){
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
Bitmap result = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
@@ -81,7 +81,7 @@ public class ConvolutionMatrix {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setAll(double value) {
|
||||
public void setAll(double value){
|
||||
for (int x = 0; x < SIZE; ++x) {
|
||||
for (int y = 0; y < SIZE; ++y) {
|
||||
Matrix[x][y] = value;
|
||||
@@ -89,7 +89,7 @@ public class ConvolutionMatrix {
|
||||
}
|
||||
}
|
||||
|
||||
public void applyConfig(double[][] config) {
|
||||
public void applyConfig(double[][] config){
|
||||
for (int x = 0; x < SIZE; ++x) {
|
||||
for (int y = 0; y < SIZE; ++y) {
|
||||
Matrix[x][y] = config[x][y];
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package ru.vtosters.lite.ui.wallpapers;
|
||||
|
||||
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.removeWallpaper;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -20,22 +19,41 @@ import com.vk.medianative.MediaNative;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ImageFilters {
|
||||
public class ImageFilters{
|
||||
public static final double PI = 3.14159d;
|
||||
public static final double HALF_CIRCLE_DEGREE = 180d;
|
||||
public static final double RANGE = 256d;
|
||||
public static final int COLOR_MIN = 0x00;
|
||||
public static final int COLOR_MAX = 0xFF;
|
||||
|
||||
public static Drawable getFilteredDrawable(Drawable orig) {
|
||||
public static Drawable getFilteredDrawable(Drawable orig){
|
||||
if (orig == null) return null;
|
||||
if (!(orig instanceof BitmapDrawable)) return orig;
|
||||
|
||||
if (!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")) {
|
||||
orig = getBlurredWallpaper(orig, getRadius());
|
||||
}
|
||||
|
||||
if (!getPreferences().getString("msg_dim", "off").equals("off")) {
|
||||
orig = getDimmed(orig);
|
||||
}
|
||||
|
||||
if (!getPreferences().getString("msg_mosaic", "disabled").equals("disabled")) {
|
||||
orig = getMosaic(orig);
|
||||
}
|
||||
|
||||
if (!hasVerification()) {
|
||||
return orig;
|
||||
}
|
||||
|
||||
if (getPreferences().getBoolean("msg_monochrome", false)) {
|
||||
orig = getMonochrome(orig);
|
||||
}
|
||||
|
||||
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
|
||||
|
||||
|
||||
Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true);
|
||||
|
||||
|
||||
if (getPreferences().getBoolean("msg_invert", false)) {
|
||||
instance = applyInvertEffect(instance);
|
||||
}
|
||||
@@ -63,7 +81,19 @@ public class ImageFilters {
|
||||
return new BitmapDrawable(getResources(), instance);
|
||||
}
|
||||
|
||||
public static Drawable getBlurredWallpaper(Drawable orig, int radius) {
|
||||
private static int getRadius(){
|
||||
String radius = getPreferences().getString("msg_blur_radius", "disabled");
|
||||
switch(radius) {
|
||||
case "low":
|
||||
return 8;
|
||||
case "med":
|
||||
return 14;
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getBlurredWallpaper(Drawable orig, int radius){
|
||||
try {
|
||||
if (orig == null) return null;
|
||||
if (!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable
|
||||
@@ -79,7 +109,7 @@ public class ImageFilters {
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getMosaic(Drawable orig) {
|
||||
public static Drawable getMosaic(Drawable orig){
|
||||
int scale = 100;
|
||||
|
||||
if (orig == null) return null;
|
||||
@@ -92,7 +122,7 @@ public class ImageFilters {
|
||||
|
||||
String radius = getPreferences().getString("msg_mosaic", "disabled");
|
||||
|
||||
switch (radius) {
|
||||
switch(radius) {
|
||||
case "high":
|
||||
scale = 25;
|
||||
break;
|
||||
@@ -109,17 +139,15 @@ public class ImageFilters {
|
||||
return new BitmapDrawable(getResources(), mosaicBitmap);
|
||||
}
|
||||
|
||||
public static Drawable getDimmed(Drawable orig) {
|
||||
public static Drawable getDimmed(Drawable orig){
|
||||
if (orig == null) return null;
|
||||
if (!(orig instanceof BitmapDrawable)) return orig;
|
||||
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
|
||||
|
||||
|
||||
Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true);
|
||||
|
||||
|
||||
String radius = getPreferences().getString("msg_dim", "disabled");
|
||||
switch (radius) {
|
||||
switch(radius) {
|
||||
case "dim_black":
|
||||
darken(instance);
|
||||
case "dim_white":
|
||||
@@ -128,7 +156,7 @@ public class ImageFilters {
|
||||
return new BitmapDrawable(getResources(), instance);
|
||||
}
|
||||
|
||||
public static Drawable getMonochrome(Drawable orig) {
|
||||
public static Drawable getMonochrome(Drawable orig){
|
||||
if (orig == null) return null;
|
||||
if (!(orig instanceof BitmapDrawable)) return orig;
|
||||
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
|
||||
@@ -151,7 +179,7 @@ public class ImageFilters {
|
||||
return new BitmapDrawable(getResources(), bwBitmap);
|
||||
}
|
||||
|
||||
private static void darken(Bitmap bm) {
|
||||
private static void darken(Bitmap bm){
|
||||
try {
|
||||
Canvas canvas = new Canvas(bm);
|
||||
Paint p = new Paint(Color.RED);
|
||||
@@ -163,7 +191,7 @@ public class ImageFilters {
|
||||
}
|
||||
}
|
||||
|
||||
private static void lighten(Bitmap bm) {
|
||||
private static void lighten(Bitmap bm){
|
||||
try {
|
||||
Canvas canvas = new Canvas(bm);
|
||||
Paint p = new Paint(Color.RED);
|
||||
@@ -175,7 +203,7 @@ public class ImageFilters {
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap applyInvertEffect(Bitmap src) {
|
||||
public static Bitmap applyInvertEffect(Bitmap src){
|
||||
// create new bitmap with the same settings as source bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
|
||||
// color info
|
||||
@@ -205,7 +233,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public static Bitmap applySepiaEffect(Bitmap src) {
|
||||
public static Bitmap applySepiaEffect(Bitmap src){
|
||||
// image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -242,8 +270,8 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public static Bitmap applyEmbossEffect(Bitmap src) {
|
||||
double[][] EmbossConfig = new double[][]{
|
||||
public static Bitmap applyEmbossEffect(Bitmap src){
|
||||
double[][] EmbossConfig = new double[][] {
|
||||
{-1, 0, -1},
|
||||
{0, 4, 0},
|
||||
{-1, 0, -1}
|
||||
@@ -255,7 +283,7 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public static Bitmap applyEngraveEffect(Bitmap src) {
|
||||
public static Bitmap applyEngraveEffect(Bitmap src){
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.setAll(0);
|
||||
convMatrix.Matrix[0][0] = -2;
|
||||
@@ -265,7 +293,7 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public static Bitmap applyFleaEffect(Bitmap source) {
|
||||
public static Bitmap applyFleaEffect(Bitmap source){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
@@ -294,7 +322,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public static Bitmap applySnowEffect(Bitmap source) {
|
||||
public static Bitmap applySnowEffect(Bitmap source){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
@@ -327,7 +355,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyDecreaseColorDepthEffect(Bitmap src, int bitOffset) {
|
||||
public Bitmap applyDecreaseColorDepthEffect(Bitmap src, int bitOffset){
|
||||
// get image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -370,7 +398,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyContrastEffect(Bitmap src, double value) {
|
||||
public Bitmap applyContrastEffect(Bitmap src, double value){
|
||||
// image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -422,7 +450,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyBrightnessEffect(Bitmap src, int value) {
|
||||
public Bitmap applyBrightnessEffect(Bitmap src, int value){
|
||||
// image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -473,8 +501,8 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyGaussianBlurEffect(Bitmap src) {
|
||||
double[][] GaussianBlurConfig = new double[][]{
|
||||
public Bitmap applyGaussianBlurEffect(Bitmap src){
|
||||
double[][] GaussianBlurConfig = new double[][] {
|
||||
{1, 2, 1},
|
||||
{2, 4, 2},
|
||||
{1, 2, 1}
|
||||
@@ -486,8 +514,8 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applySharpenEffect(Bitmap src, double weight) {
|
||||
double[][] SharpConfig = new double[][]{
|
||||
public Bitmap applySharpenEffect(Bitmap src, double weight){
|
||||
double[][] SharpConfig = new double[][] {
|
||||
{0, -2, 0},
|
||||
{-2, weight, -2},
|
||||
{0, -2, 0}
|
||||
@@ -498,8 +526,8 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applyMeanRemovalEffect(Bitmap src) {
|
||||
double[][] MeanRemovalConfig = new double[][]{
|
||||
public Bitmap applyMeanRemovalEffect(Bitmap src){
|
||||
double[][] MeanRemovalConfig = new double[][] {
|
||||
{-1, -1, -1},
|
||||
{-1, 9, -1},
|
||||
{-1, -1, -1}
|
||||
@@ -511,7 +539,7 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applySmoothEffect(Bitmap src, double value) {
|
||||
public Bitmap applySmoothEffect(Bitmap src, double value){
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.setAll(1);
|
||||
convMatrix.Matrix[1][1] = value;
|
||||
@@ -520,7 +548,7 @@ public class ImageFilters {
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applyBoostEffect(Bitmap src, int type, float percent) {
|
||||
public Bitmap applyBoostEffect(Bitmap src, int type, float percent){
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
@@ -551,7 +579,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyTintEffect(Bitmap src, int degree) {
|
||||
public Bitmap applyTintEffect(Bitmap src, int degree){
|
||||
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
@@ -595,7 +623,7 @@ public class ImageFilters {
|
||||
return outBitmap;
|
||||
}
|
||||
|
||||
public Bitmap applyBlackFilter(Bitmap source) {
|
||||
public Bitmap applyBlackFilter(Bitmap source){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
@@ -628,7 +656,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyShadingFilter(Bitmap source, int shadingColor) {
|
||||
public Bitmap applyShadingFilter(Bitmap source, int shadingColor){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
@@ -652,7 +680,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applySaturationFilter(Bitmap source, int level) {
|
||||
public Bitmap applySaturationFilter(Bitmap source, int level){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
@@ -682,7 +710,7 @@ public class ImageFilters {
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyHueFilter(Bitmap source, int level) {
|
||||
public Bitmap applyHueFilter(Bitmap source, int level){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
|
||||
@@ -32,15 +32,15 @@ import java.io.OutputStream;
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{
|
||||
|
||||
private WallpaperPreferences mWPPreviewPref;
|
||||
|
||||
public static void copyStream(InputStream copyFrom, OutputStream copyTo) throws IOException {
|
||||
public static void copyStream(InputStream copyFrom, OutputStream copyTo) throws IOException{
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = copyFrom.read(buffer)) > 0) {
|
||||
while((length = copyFrom.read(buffer)) > 0) {
|
||||
copyTo.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
public void onCreate(Bundle bundle){
|
||||
super.onCreate(bundle);
|
||||
|
||||
int vtosterXml = getIdentifier("empty", "xml");
|
||||
@@ -86,16 +86,16 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
});
|
||||
}
|
||||
|
||||
PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", AndroidUtils.getString("filter_blur"), AndroidUtils.getArray("filter_types"), new String[]{
|
||||
PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", AndroidUtils.getString("filter_blur"), AndroidUtils.getArray("filter_types"), new String[] {
|
||||
"disabled", "low", "med", "high"
|
||||
});
|
||||
|
||||
PreferencesUtil.addListPreference(this, "msg_dim", "off", AndroidUtils.getString("filter_dim"), AndroidUtils.getArray("filter_dim_types"), new String[]{
|
||||
PreferencesUtil.addListPreference(this, "msg_dim", "off", AndroidUtils.getString("filter_dim"), AndroidUtils.getArray("filter_dim_types"), new String[] {
|
||||
"off", "dim_black", "dim_white"
|
||||
});
|
||||
|
||||
|
||||
PreferencesUtil.addListPreference(this, "msg_mosaic", "disabled", AndroidUtils.getString("filter_mosaic"), AndroidUtils.getArray("filter_types"), new String[]{
|
||||
PreferencesUtil.addListPreference(this, "msg_mosaic", "disabled", AndroidUtils.getString("filter_mosaic"), AndroidUtils.getArray("filter_types"), new String[] {
|
||||
"disabled", "low", "med", "high"
|
||||
});
|
||||
|
||||
@@ -199,13 +199,14 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int i, int i1, @Nullable Intent intent) {
|
||||
public void onActivityResult(int i, int i1, @Nullable Intent intent){
|
||||
super.onActivityResult(i, i1, intent);
|
||||
|
||||
if (intent == null || intent.getData() == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
removeWallpaper();
|
||||
InputStream fileInputStream = requireActivity().getContentResolver().openInputStream(intent.getData());
|
||||
OutputStream outputStream = new FileOutputStream(getWallpaperFile());
|
||||
|
||||
@@ -216,20 +217,21 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
|
||||
if (i == 1488) {
|
||||
mWPPreviewPref.redraw();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(requireActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeStickCache() {
|
||||
private void removeStickCache(){
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().apply();
|
||||
ImEngineProvider.b().a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int T4() {
|
||||
public int T4(){
|
||||
return getIdentifier("wallpapers", "string");
|
||||
}
|
||||
}
|
||||
@@ -18,31 +18,31 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import ru.vtosters.lite.ui.adapters.MessagesPreviewAdapter;
|
||||
|
||||
public class WallpaperPreferences extends Preference {
|
||||
public class WallpaperPreferences extends Preference{
|
||||
|
||||
private MessagesPreviewAdapter mAdapter;
|
||||
RecyclerView mRecyclerView;
|
||||
ImageView mChatBackground;
|
||||
private MessagesPreviewAdapter mAdapter;
|
||||
|
||||
public WallpaperPreferences(Context context) {
|
||||
public WallpaperPreferences(Context context){
|
||||
this(context, null, -1, -1);
|
||||
}
|
||||
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet) {
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet){
|
||||
this(context, attributeSet, -1, -1);
|
||||
}
|
||||
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr) {
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr){
|
||||
this(context, attributeSet, defStyleAttr, -1);
|
||||
}
|
||||
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr, int i1) {
|
||||
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr, int i1){
|
||||
super(context, attributeSet, defStyleAttr, i1);
|
||||
setLayoutResource(getIdentifier("wppreview", "layout"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder preferenceViewHolder) {
|
||||
public void onBindViewHolder(PreferenceViewHolder preferenceViewHolder){
|
||||
super.onBindViewHolder(preferenceViewHolder);
|
||||
|
||||
mRecyclerView = (RecyclerView) preferenceViewHolder.findViewById(getIdentifier("install_btn_container", "id"));
|
||||
@@ -56,7 +56,7 @@ public class WallpaperPreferences extends Preference {
|
||||
requestBg();
|
||||
}
|
||||
|
||||
private void requestBg() {
|
||||
private void requestBg(){
|
||||
final Drawable drawable = getWallpaper();
|
||||
|
||||
if (drawable != null && getWallpaperFile().exists())
|
||||
@@ -66,7 +66,7 @@ public class WallpaperPreferences extends Preference {
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
void redraw() {
|
||||
void redraw(){
|
||||
mAdapter.notifyDataSetChanged();
|
||||
requestBg();
|
||||
}
|
||||
|
||||
@@ -1,50 +1,113 @@
|
||||
package ru.vtosters.lite.ui.wallpapers;
|
||||
|
||||
import static com.vk.im.engine.h.im_bg_chat;
|
||||
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getBlurredWallpaper;
|
||||
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getDimmed;
|
||||
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getFilteredDrawable;
|
||||
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getMonochrome;
|
||||
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getMosaic;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import vigo.sdk.Log;
|
||||
|
||||
public class WallpapersHooks {
|
||||
public class WallpapersHooks{
|
||||
private static final boolean compress = getBoolValue("compresswp", true);
|
||||
private static File mWallpaperFile;
|
||||
private static File mWallpaperFilteredFile; // TODO
|
||||
|
||||
private static File mWallpaperFilteredFile;
|
||||
private static Drawable mWallpaper;
|
||||
private static boolean mUpdateWallpaperRequested = true;
|
||||
private static boolean mUpdateWallpaperFileRequested = true;
|
||||
|
||||
public static File getWallpaperFile() {
|
||||
public static File getWallpaperFile(){
|
||||
if (mWallpaperFile == null) {
|
||||
return mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.png");
|
||||
mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.webp");
|
||||
|
||||
Log.d("Wallpapers", "updated");
|
||||
}
|
||||
|
||||
if (compress) {
|
||||
mWallpaperFilteredFile = getCompressedFile();
|
||||
}
|
||||
|
||||
if (compress && mWallpaperFilteredFile != null) {
|
||||
return mWallpaperFilteredFile;
|
||||
}
|
||||
|
||||
return mWallpaperFile;
|
||||
}
|
||||
|
||||
private static Boolean eligibleWallpaperFile(File file) {
|
||||
public static File getCompressedFile(){
|
||||
File file = null;
|
||||
String temp = getGlobalContext().getFilesDir() + File.separator + "tempwp.webp";
|
||||
|
||||
if (mWallpaperFile.exists()) {
|
||||
try {
|
||||
file = new File(temp);
|
||||
file.createNewFile();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
BitmapFactory.decodeFile(mWallpaperFile.getAbsolutePath()).compress(Bitmap.CompressFormat.WEBP, 85, bos);
|
||||
byte[] bitmapdata = bos.toByteArray();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(bitmapdata);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d("Wallpapers", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public static Drawable getFilteredFile(){
|
||||
File file = null;
|
||||
File wp = compress ? mWallpaperFilteredFile : mWallpaperFile;
|
||||
String temp = getGlobalContext().getFilesDir() + File.separator + "filteredwp.webp";
|
||||
|
||||
if (mWallpaperFile.exists() && mUpdateWallpaperFileRequested) {
|
||||
try {
|
||||
file = new File(temp);
|
||||
file.createNewFile();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
((BitmapDrawable) getFilteredDrawable(Drawable.createFromPath(wp.getAbsolutePath()))).getBitmap().compress(Bitmap.CompressFormat.WEBP, 98, bos);
|
||||
byte[] bitmapdata = bos.toByteArray();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(bitmapdata);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d("Wallpapers", e.getMessage());
|
||||
}
|
||||
|
||||
mUpdateWallpaperFileRequested = false;
|
||||
}
|
||||
|
||||
try {
|
||||
return Drawable.createFromPath(temp);
|
||||
} catch (Exception e) {
|
||||
return Drawable.createFromPath(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean eligibleWallpaperFile(File file){
|
||||
if (file.length() >= 6291456) {
|
||||
sendToast("Размер файла превышает лимит 6 MB");
|
||||
removeWallpaper();
|
||||
@@ -54,70 +117,26 @@ public class WallpapersHooks {
|
||||
}
|
||||
}
|
||||
|
||||
public static File compress(File file){
|
||||
return file;
|
||||
// try {
|
||||
// BitmapFactory.Options o = new BitmapFactory.Options();
|
||||
// o.inJustDecodeBounds = true;
|
||||
// o.inSampleSize = 6;
|
||||
//
|
||||
// FileInputStream inputStream = new FileInputStream(file);
|
||||
// BitmapFactory.decodeStream(inputStream, null, o);
|
||||
// inputStream.close();
|
||||
//
|
||||
// final int REQUIRED_SIZE=200;
|
||||
//
|
||||
// int scale = 1;
|
||||
// while(o.outWidth / scale / 2 >= REQUIRED_SIZE && o.outHeight / scale / 2 >= REQUIRED_SIZE) {
|
||||
// scale *= 2;
|
||||
// }
|
||||
//
|
||||
// BitmapFactory.Options o2 = new BitmapFactory.Options();
|
||||
// o2.inSampleSize = scale;
|
||||
// inputStream = new FileInputStream(file);
|
||||
//
|
||||
// Bitmap selectedBitmap = BitmapFactory.decodeStream(inputStream, null, o2);
|
||||
// inputStream.close();
|
||||
//
|
||||
// File outPutFile = File.createTempFile("wallpaper_temp","image");
|
||||
//
|
||||
// FileOutputStream outputStream = new FileOutputStream(outPutFile);
|
||||
//
|
||||
// selectedBitmap.compress(Bitmap.CompressFormat.PNG, 85 , outputStream);
|
||||
//
|
||||
// outputStream.close();
|
||||
//
|
||||
// return outPutFile;
|
||||
// } catch (Exception e) {
|
||||
// Log.d("Wallpapers", e.getMessage());
|
||||
// return file;
|
||||
// }
|
||||
}
|
||||
|
||||
public static void setBg(View view) {
|
||||
// if (getWallpaper() != null) {
|
||||
// ((ImageView) view).setImageDrawable(getWallpaper()); // set picture to background
|
||||
// return;
|
||||
// }
|
||||
public static void setBg(View view){
|
||||
if (getWallpaper() != null) {
|
||||
((ImageView) view).setImageDrawable(getFilteredFile()); // set picture to background
|
||||
return;
|
||||
}
|
||||
|
||||
view.setBackgroundColor(ThemesUtils.getColorFromAttr(im_bg_chat)); // set default bg color
|
||||
}
|
||||
|
||||
public static String getWallpaperUrl() {
|
||||
// var file = getWallpaperFile();
|
||||
//
|
||||
// if (file.exists() && eligibleWallpaperFile(file)) {
|
||||
// if (getBoolValue("compresswp", true)) {
|
||||
// return compress(file).getAbsolutePath();
|
||||
// } else {
|
||||
// return file.getAbsolutePath();
|
||||
// }
|
||||
// }
|
||||
public static String getWallpaperUrl(){
|
||||
var file = getWallpaperFile();
|
||||
|
||||
if (file.exists() && eligibleWallpaperFile(file)) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
return "default";
|
||||
}
|
||||
|
||||
public static Drawable getWallpaper() {
|
||||
public static Drawable getWallpaper(){
|
||||
if (mWallpaper == null || mUpdateWallpaperRequested) {
|
||||
String url = getWallpaperUrl();
|
||||
|
||||
@@ -131,26 +150,9 @@ public class WallpapersHooks {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")) {
|
||||
mWallpaper = getBlurredWallpaper(drawable, getRadius());
|
||||
} else {
|
||||
mWallpaper = drawable;
|
||||
}
|
||||
if (!getPreferences().getString("msg_dim", "off").equals("off")) {
|
||||
mWallpaper = getDimmed(mWallpaper);
|
||||
}
|
||||
mWallpaper = drawable;
|
||||
|
||||
if (!getPreferences().getString("msg_mosaic", "disabled").equals("disabled")) {
|
||||
mWallpaper = getMosaic(mWallpaper);
|
||||
}
|
||||
|
||||
if (hasVerification()) {
|
||||
if (getPreferences().getBoolean("msg_monochrome", false)) {
|
||||
mWallpaper = getMonochrome(mWallpaper);
|
||||
}
|
||||
|
||||
mWallpaper = getFilteredDrawable(mWallpaper);
|
||||
}
|
||||
mWallpaper = getFilteredDrawable(mWallpaper);
|
||||
|
||||
mUpdateWallpaperRequested = false;
|
||||
}
|
||||
@@ -158,25 +160,14 @@ public class WallpapersHooks {
|
||||
return mWallpaper;
|
||||
}
|
||||
|
||||
public static void requestUpdateWallpaper() {
|
||||
public static void requestUpdateWallpaper(){
|
||||
mUpdateWallpaperRequested = true;
|
||||
mUpdateWallpaperFileRequested = true;
|
||||
}
|
||||
|
||||
private static int getRadius() {
|
||||
public static String getRadiusSummary(){
|
||||
String radius = getPreferences().getString("msg_blur_radius", "disabled");
|
||||
switch (radius) {
|
||||
case "low":
|
||||
return 8;
|
||||
case "med":
|
||||
return 14;
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRadiusSummary() {
|
||||
String radius = getPreferences().getString("msg_blur_radius", "disabled");
|
||||
switch (radius) {
|
||||
switch(radius) {
|
||||
case "low":
|
||||
return AndroidUtils.getString("wallpapers_low");
|
||||
case "med":
|
||||
@@ -188,21 +179,21 @@ public class WallpapersHooks {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDimmingSummary() {
|
||||
public static String getDimmingSummary(){
|
||||
String radius = getPreferences().getString("msg_dim", "disabled");
|
||||
switch (radius) {
|
||||
switch(radius) {
|
||||
case "dim_black":
|
||||
return AndroidUtils.getString("wallpapers_dim_black");
|
||||
case "dim_white":
|
||||
return AndroidUtils.getString("wallpapers_dim_white");
|
||||
return AndroidUtils.getString("wallpapers_dim_white");
|
||||
default:
|
||||
return AndroidUtils.getString("wallpapers_disabled");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMosaicSummary() {
|
||||
public static String getMosaicSummary(){
|
||||
String radius = getPreferences().getString("msg_mosaic", "disabled");
|
||||
switch (radius) {
|
||||
switch(radius) {
|
||||
case "low":
|
||||
return AndroidUtils.getString("wallpapers_low");
|
||||
case "med":
|
||||
@@ -215,7 +206,14 @@ public class WallpapersHooks {
|
||||
}
|
||||
|
||||
|
||||
public static void removeWallpaper() {
|
||||
getWallpaperFile().delete();
|
||||
public static void removeWallpaper(){
|
||||
try {
|
||||
new File(getGlobalContext().getFilesDir(), "wallpaper.webp").delete();
|
||||
new File(getGlobalContext().getFilesDir(), "tempwp.webp").delete();
|
||||
mWallpaperFile = null;
|
||||
mWallpaperFilteredFile = null;
|
||||
} catch (Exception e) {
|
||||
Log.d("Wallpapers", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user