From 652f5e665f9acf7ac949b92535072a4c17b25545 Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Sat, 27 Aug 2022 15:53:56 +0300 Subject: [PATCH] wp disabled --- .../lite/ui/fragments/MessagesFragment.java | 10 +- .../lite/ui/wallpapers/ImageFilters.java | 64 ---------- .../lite/ui/wallpapers/WallpapersHooks.java | 114 +++++++++--------- 3 files changed, 63 insertions(+), 125 deletions(-) diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/MessagesFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/MessagesFragment.java index 5a997fb0d..80bbe047b 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/MessagesFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/MessagesFragment.java @@ -3,6 +3,7 @@ package ru.vtosters.lite.ui.fragments; 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; @@ -100,10 +101,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); +// Context context = getContext(); +// Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context); +// a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +// context.startActivity(a2); + sendToast("Обои временно недоступны. Следите за новостями на @vtosters в Telegram"); return true; } } diff --git a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/ImageFilters.java b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/ImageFilters.java index 92d3bc450..d8fc96a2b 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/ImageFilters.java +++ b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/ImageFilters.java @@ -32,21 +32,9 @@ public class ImageFilters { if (!(orig instanceof BitmapDrawable)) return orig; Bitmap bm = ((BitmapDrawable) orig).getBitmap(); - if (bm == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true); - if (instance == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } if (getPreferences().getBoolean("msg_invert", false)) { instance = applyInvertEffect(instance); @@ -81,22 +69,8 @@ public class ImageFilters { if (!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable Bitmap bm = ((BitmapDrawable) orig).getBitmap(); - if (bm == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } - Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true); - if (instance == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } - MediaNative.blurBitmap(instance, radius); return new BitmapDrawable(getResources(), instance); } catch (Exception e) { @@ -112,21 +86,9 @@ public class ImageFilters { if (!(orig instanceof BitmapDrawable)) return orig; Bitmap bm = ((BitmapDrawable) orig).getBitmap(); - if (bm == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true); - if (instance == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } String radius = getPreferences().getString("msg_mosaic", "disabled"); @@ -152,21 +114,9 @@ public class ImageFilters { if (!(orig instanceof BitmapDrawable)) return orig; Bitmap bm = ((BitmapDrawable) orig).getBitmap(); - if (bm == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true); - if (instance == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } String radius = getPreferences().getString("msg_dim", "disabled"); switch (radius) { @@ -183,22 +133,8 @@ public class ImageFilters { if (!(orig instanceof BitmapDrawable)) return orig; Bitmap bm = ((BitmapDrawable) orig).getBitmap(); - if (bm == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } - Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true); - if (instance == null) { - Log.d("Wallpaper", "bitmap null"); - sendToast("Ошибка при установке фильтра. Сбрасываем настройки на по умолчанию"); - removeWallpaper(); - return orig; - } - Bitmap bwBitmap = Bitmap.createBitmap(instance.getWidth(), instance.getHeight(), Bitmap.Config.RGB_565); float[] hsv = new float[3]; for (int col = 0; col < instance.getWidth(); col++) { diff --git a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java index c9062f294..08cc44fd5 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java +++ b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java @@ -31,12 +31,17 @@ import ru.vtosters.lite.utils.ThemesUtils; public class WallpapersHooks { private static File mWallpaperFile; + private static File mWallpaperFilteredFile; // TODO private static Drawable mWallpaper; private static boolean mUpdateWallpaperRequested = true; public static File getWallpaperFile() { - return mWallpaperFile == null ? mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.png") : mWallpaperFile; + if (mWallpaperFile == null) { + return mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.png"); + } + + return mWallpaperFile; } private static Boolean eligibleWallpaperFile(File file) { @@ -50,67 +55,64 @@ public class WallpapersHooks { } public static File compress(File 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"); - outPutFile.deleteOnExit(); - FileOutputStream outputStream = new FileOutputStream(outPutFile); - - try { - selectedBitmap.compress(Bitmap.CompressFormat.PNG, 85 , outputStream); - } catch (Exception e) { - Log.e("WallpapersCompression", e.getMessage()); - } - - outputStream.close(); - - return outPutFile; - } catch (Exception e) { - Log.d("Wallpapers", e.getMessage()); - return 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; - } +// if (getWallpaper() != null) { +// ((ImageView) view).setImageDrawable(getWallpaper()); // 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(); - } - } +// var file = getWallpaperFile(); +// +// if (file.exists() && eligibleWallpaperFile(file)) { +// if (getBoolValue("compresswp", true)) { +// return compress(file).getAbsolutePath(); +// } else { +// return file.getAbsolutePath(); +// } +// } return "default"; } @@ -125,9 +127,7 @@ public class WallpapersHooks { Drawable drawable = Drawable.createFromPath(getWallpaperUrl()); - if (drawable == null || ((BitmapDrawable) drawable).getBitmap() == null) { - Log.d("Wallpaper", "drawable null"); - removeWallpaper(); + if (drawable == null) { return null; }