Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8eb725148f | ||
|
|
af1d175415 | ||
|
|
92edbd4686 | ||
|
|
8d9812ebe0 | ||
|
|
33477e809c | ||
|
|
04f4f7d2ad | ||
|
|
80b8399cb8 | ||
|
|
483c9eda4d | ||
|
|
c76a7a5332 | ||
|
|
c470062d70 |
@@ -7,7 +7,6 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
@@ -17,7 +16,7 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.vk.core.dialogs.actionspopup.ActionsPopup;
|
||||
import com.vk.core.drawable.RecoloredDrawable;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vk.core.util.ContextExtKt;
|
||||
import com.vk.core.util.ToastUtils;
|
||||
@@ -41,7 +40,7 @@ import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class PhotoViewer {
|
||||
static OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
@@ -49,12 +48,12 @@ public class PhotoViewer {
|
||||
public static boolean interceptClick(AttachmentWithMedia attachment, MenuItem item, View view) {
|
||||
if (item.getItemId() == R.id.search_photo) {
|
||||
if (attachment instanceof PhotoAttachment) {
|
||||
searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment));
|
||||
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromPhotoAttachment((PhotoAttachment) attachment));
|
||||
} else if (attachment instanceof DocumentAttachment) {
|
||||
var documentAttachment = (DocumentAttachment) attachment;
|
||||
if (documentAttachment.J != null)
|
||||
try {
|
||||
searchPhoto(getUrlFromDocumentAttachment(documentAttachment));
|
||||
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromDocumentAttachment(documentAttachment));
|
||||
} catch (Exception e) {
|
||||
ToastUtils.a(R.string.photo_get_error);
|
||||
}
|
||||
@@ -103,12 +102,12 @@ public class PhotoViewer {
|
||||
false,
|
||||
() -> {
|
||||
if (attachment instanceof PhotoAttachment) {
|
||||
searchPhoto(getUrlFromPhotoAttachment((PhotoAttachment) attachment));
|
||||
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromPhotoAttachment((PhotoAttachment) attachment));
|
||||
} else if (attachment instanceof DocumentAttachment) {
|
||||
var documentAttachment = (DocumentAttachment) attachment;
|
||||
if (documentAttachment.J != null)
|
||||
try {
|
||||
searchPhoto(getUrlFromDocumentAttachment(documentAttachment));
|
||||
searchDialog(LifecycleUtils.getCurrentActivity(), getUrlFromDocumentAttachment(documentAttachment));
|
||||
} catch (Exception e) {
|
||||
ToastUtils.a(R.string.photo_get_error);
|
||||
}
|
||||
@@ -187,21 +186,54 @@ public class PhotoViewer {
|
||||
return max.url;
|
||||
}
|
||||
|
||||
private static void searchPhoto(String url) {
|
||||
if (url == null || url.isEmpty()) return;
|
||||
switch (getPreferences().getInt("search_engine", 0)) {
|
||||
case 0:
|
||||
private static void searchDialog(Context context, String url) {
|
||||
if (selectedEngine() == 0) {
|
||||
var items = new String[]{
|
||||
"Google", "Yandex", "Bing", "TraceMoe", "Ascii2d", "Saucenao"
|
||||
};
|
||||
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setItems(items, (dl, i) -> {
|
||||
searchPhoto(i + 1, url);
|
||||
})
|
||||
.show();
|
||||
} else {
|
||||
searchPhoto(selectedEngine(), url);
|
||||
}
|
||||
}
|
||||
|
||||
private static int selectedEngine() {
|
||||
return getPreferences().getInt("search_engine", 0);
|
||||
}
|
||||
|
||||
private static void searchPhoto(int i, String url) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
searchWithYandex(url);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
searchWithGoogle(url);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
searchWithBing(url);
|
||||
break;
|
||||
case 4:
|
||||
searchWithTraceMoe(url);
|
||||
break;
|
||||
case 5:
|
||||
searchWithAscii2d(url);
|
||||
break;
|
||||
case 6:
|
||||
searchWithSaucenao(url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void searchPhoto(String url) {
|
||||
if (url == null || url.isEmpty()) return;
|
||||
searchPhoto(selectedEngine(), url);
|
||||
}
|
||||
|
||||
private static void searchWithYandex(String url) {
|
||||
var request = new Request.a()
|
||||
.b(String.format("https://yandex.ru/images-apphost/image-download?url=%s&images_avatars_size=preview&images_avatars_namespace=images-cbir",
|
||||
@@ -232,6 +264,18 @@ public class PhotoViewer {
|
||||
openUrl("https://www.google.com/searchbyimage?image_url=" + URLEncoder.encode(url) + "&client=app");
|
||||
}
|
||||
|
||||
private static void searchWithTraceMoe(String url) {
|
||||
openUrl("https://trace.moe/?url=" + URLEncoder.encode(url));
|
||||
}
|
||||
|
||||
private static void searchWithAscii2d(String url) {
|
||||
openUrl("https://ascii2d.net/search/url/" + URLEncoder.encode(url));
|
||||
}
|
||||
|
||||
private static void searchWithSaucenao(String url) {
|
||||
openUrl("https://saucenao.com/search.php?url=" + URLEncoder.encode(url));
|
||||
}
|
||||
|
||||
private static void searchWithBing(String url) {
|
||||
openUrl("https://www.bing.com/images/search?view=detailv2&iss=SBI&form=SBIIDP&sbisrc=UrlPaste&q=imgurl:"
|
||||
+ URLEncoder.encode(url));
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ThemesCore {
|
||||
themedColors.put(R.attr.im_reply_separator, accentColor);
|
||||
themedColors.put(R.attr.im_text_name, accentColor);
|
||||
|
||||
wallLightColor = ThemesUtils.lighten(accentColor, 0.67f);
|
||||
wallLightColor = ThemesUtils.lighten(accentColor, 0.76f);
|
||||
|
||||
themedColors.put(R.attr.im_ic_send_msg, accentColor);
|
||||
themedColors.put(R.attr.im_bubble_wallpaper_outgoing, accentColor);
|
||||
|
||||
@@ -41,16 +41,14 @@ public class ThemesHacks {
|
||||
}
|
||||
|
||||
public static int getHackedColor(@NonNull Context context, @ColorRes int color) {
|
||||
if (ThemesCore.isCachedAccents() && ColorReferences.isAccentedColor(context.getColor(color))) {
|
||||
if (ThemesCore.isCachedAccents() && ColorReferences.isAccentedColor(context.getResources().getColor(color))) {
|
||||
return ThemesUtils.getAccentColor();
|
||||
}
|
||||
|
||||
if (ThemesCore.isCachedAccents() && ColorReferences.isMutedAccentedColor(context.getColor(color))) {
|
||||
if (ThemesCore.isCachedAccents() && ColorReferences.isMutedAccentedColor(context.getResources().getColor(color))) {
|
||||
return ThemesUtils.getMutedAccentColor();
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT > 23) {
|
||||
return context.getColor(color);
|
||||
} else return context.getResources().getColor(color);
|
||||
return Build.VERSION.SDK_INT > 23 ? context.getColor(color) : context.getResources().getColor(color);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,25 @@
|
||||
package ru.vtosters.lite.themes.palettes;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.themes.items.VTLPalette;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.IOUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.themes.items.VTLPalette;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.IOUtils;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class PalettesManager {
|
||||
|
||||
@@ -40,6 +44,13 @@ public class PalettesManager {
|
||||
mPalettes.clear();
|
||||
if (!PALETTES_DIR.exists())
|
||||
PALETTES_DIR.mkdirs();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 23 && !Environment.getExternalStorageDirectory().canWrite()) {
|
||||
makeText(getGlobalContext(), "Не выдано разрешение на запись и чтение файлов", Toast.LENGTH_LONG).show();
|
||||
LifecycleUtils.getCurrentActivity().requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
|
||||
return;
|
||||
}
|
||||
|
||||
final var palettes = PALETTES_DIR.listFiles((dir, name) -> name.endsWith(".json"));
|
||||
if (palettes == null || palettes.length == 0)
|
||||
copyPaletteFromAssets();
|
||||
@@ -67,8 +78,12 @@ public class PalettesManager {
|
||||
|
||||
private void parsePalettes() {
|
||||
var arr = PALETTES_DIR.listFiles((dir, name) -> name.endsWith(".json"));
|
||||
if (arr == null || arr.length == 0)
|
||||
throw new RuntimeException("Can't load palettes");
|
||||
|
||||
if (arr == null || arr.length == 0) {
|
||||
Log.d("PalettesManager", "arr.length null");
|
||||
return;
|
||||
}
|
||||
|
||||
for (var file : arr) {
|
||||
try {
|
||||
var json = new JSONObject(IOUtils.readAllLines(file));
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
|
||||
import static ru.vtosters.lite.music.LastFMScrobbler.isLoggedIn;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
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.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@@ -25,25 +9,16 @@ import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.network.Network;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.downloaders.VideoDownloader;
|
||||
import ru.vtosters.lite.music.LastFMScrobbler;
|
||||
@@ -52,6 +27,22 @@ import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
|
||||
import static ru.vtosters.lite.music.LastFMScrobbler.isLoggedIn;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
private static final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
@@ -148,10 +139,14 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
findPreference("select_photo_search_engine").setOnPreferenceClickListener(preference -> {
|
||||
var items = Arrays.asList(
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "По выбору"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.yandex, "Yandex"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.google, "Google"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.microsoft, "Bing")
|
||||
);
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(R.drawable.microsoft, "Bing"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "TraceMoe"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "Ascii2d"),
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(null, "Saucenao")
|
||||
);
|
||||
|
||||
var adapter = new ImagineArrayAdapter(getContext(), items);
|
||||
adapter.setSelected(getPreferences().getInt("search_engine", 0));
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.fragments.FragmentImpl;
|
||||
@@ -130,27 +133,39 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
void showColorPicker() {
|
||||
final var colorPickerView = new ColorPickerView(requireContext());
|
||||
colorPickerView.setColor(ThemesUtils.getAccentColor());
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(AndroidUtils.getString("select_color"))
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.select, (dialog, which) -> setAccentColor(colorPickerView.getColor()))
|
||||
.setView(colorPickerView)
|
||||
.show();
|
||||
|
||||
var alertDialog = new VkAlertDialog.Builder(requireContext()).create();
|
||||
alertDialog.setTitle(AndroidUtils.getString("select_color"));
|
||||
alertDialog.setButton(
|
||||
DialogInterface.BUTTON_NEGATIVE,
|
||||
requireContext().getString(R.string.cancel),
|
||||
(DialogInterface.OnClickListener) null
|
||||
);
|
||||
alertDialog.setButton(
|
||||
DialogInterface.BUTTON_POSITIVE,
|
||||
requireContext().getString(R.string.select),
|
||||
(dialog, which) -> setAccentColor(colorPickerView.getColor())
|
||||
);
|
||||
alertDialog.setView(colorPickerView);
|
||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
void showPalettesDialog() {
|
||||
final var manager = PalettesManager.getInstance();
|
||||
final var titles = new String[manager.getPalettesCount()];
|
||||
for (int i = 0; i < titles.length; ++i)
|
||||
titles[i] = manager.getPalette(i).name;
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(AndroidUtils.getString("select_palette"))
|
||||
.setItems(titles, (dialog, which) ->
|
||||
PalettesBottomSheetDialog.create(requireActivity(), manager.getPalette(which),
|
||||
(adapter, vtlcolor) -> setAccentColor(vtlcolor.color))
|
||||
)
|
||||
.setPositiveButton(R.string.cancel, null)
|
||||
.show();
|
||||
if (titles.length > 0) {
|
||||
for (int i = 0; i < titles.length; ++i)
|
||||
titles[i] = manager.getPalette(i).name;
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(AndroidUtils.getString("select_palette"))
|
||||
.setItems(titles, (dialog, which) ->
|
||||
PalettesBottomSheetDialog.create(requireActivity(), manager.getPalette(which),
|
||||
(adapter, vtlcolor) -> setAccentColor(vtlcolor.color))
|
||||
)
|
||||
.setPositiveButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
void setAccentColor(int color) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
import android.widget.EditText;
|
||||
@@ -82,30 +83,30 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
|
||||
private void openMenu(String toast) {
|
||||
if (toast != null) {
|
||||
Toast.makeText(getContext(), toast, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(requireContext(), toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).b(getContext());
|
||||
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).b(requireContext());
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
super.getContext().startActivity(intent);
|
||||
super.requireContext().startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getContext().registerReceiver(mReceiver, new IntentFilter(ACTION_RELOAD));
|
||||
requireContext().registerReceiver(mReceiver, new IntentFilter(ACTION_RELOAD));
|
||||
|
||||
mGrabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
|
||||
mService = TelegramStickersService.getInstance(getContext());
|
||||
mService = TelegramStickersService.getInstance(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
|
||||
setTitle(R.string.vtltgs);
|
||||
|
||||
FrameLayout layout = new FrameLayout(getContext());
|
||||
FrameLayout layout = new FrameLayout(requireContext());
|
||||
|
||||
mAdapter = new StickerPackAdapter();
|
||||
RecyclerView mRecycler = new RecyclerView(getContext());
|
||||
RecyclerView mRecycler = new RecyclerView(requireContext());
|
||||
|
||||
var callback = new StickerTouchHelperCallback(mAdapter);
|
||||
var touchHelper = new ItemTouchHelper(callback);
|
||||
@@ -115,7 +116,7 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
mRecycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
||||
layout.addView(mRecycler, new ViewGroup.LayoutParams(-1, -1));
|
||||
|
||||
FloatingActionButton mAddStickerPack = new FloatingActionButton(getContext());
|
||||
FloatingActionButton mAddStickerPack = new FloatingActionButton(requireContext());
|
||||
mAddStickerPack.setImageResource(R.drawable.ic_add_24);
|
||||
mAddStickerPack.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
mAddStickerPack.setOnClickListener(v2 -> fabClick());
|
||||
@@ -154,9 +155,9 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
}
|
||||
} else if (method == TYPE_DIRECT) {
|
||||
final Runnable callback = () -> {
|
||||
LinearLayout linearLayout = new LinearLayout(getContext());
|
||||
LinearLayout linearLayout = new LinearLayout(requireContext());
|
||||
|
||||
final EditText editText = new EditText(getContext());
|
||||
final EditText editText = new EditText(requireContext());
|
||||
editText.setHintTextColor(ThemesUtils.getSTextAttr());
|
||||
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
|
||||
@@ -166,7 +167,7 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickershelp1))
|
||||
.setMessage(requireContext().getString(R.string.stickershelp2))
|
||||
.setView(linearLayout)
|
||||
@@ -178,7 +179,7 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
AndroidUtils.sendToast(AndroidUtils.getString("invalid_pack_link"));
|
||||
}
|
||||
pack = parsePack(pack);
|
||||
mService.requestPackDownload(pack, new File(getContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
mService.requestPackDownload(pack, new File(requireContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
})
|
||||
.setNeutralButton(android.R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
@@ -212,9 +213,9 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
}
|
||||
|
||||
private void enterBotKey(Runnable r) {
|
||||
LinearLayout linearLayout = new LinearLayout(getContext());
|
||||
LinearLayout linearLayout = new LinearLayout(requireContext());
|
||||
|
||||
final EditText editText = new EditText(getContext());
|
||||
final EditText editText = new EditText(requireContext());
|
||||
editText.setHintTextColor(ThemesUtils.getSTextAttr());
|
||||
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
|
||||
@@ -224,7 +225,7 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickersapi5))
|
||||
.setMessage(requireContext().getString(R.string.stickersapi6))
|
||||
.setView(linearLayout)
|
||||
@@ -236,10 +237,15 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
)
|
||||
.setNeutralButton(requireContext().getString(R.string.stickersapi7),
|
||||
(dialog, which) -> new VkAlertDialog.Builder(getContext())
|
||||
(dialog, which) -> new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickersapi8))
|
||||
.setMessage(requireContext().getString(R.string.stickersapi9) +
|
||||
requireContext().getString(R.string.stickersapi10))
|
||||
.setNeutralButton("Открыть бота", (dl, i) -> {
|
||||
var intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/botfather"));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
requireActivity().startActivity(intent);
|
||||
})
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
)
|
||||
@@ -249,7 +255,7 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
private void checkApiKey(Runnable callback) {
|
||||
mGrabber.setBotApiKey(TGPref.getTGBotKey());
|
||||
|
||||
var context = getContext();
|
||||
var context = requireContext();
|
||||
|
||||
final ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
|
||||
@@ -9,8 +9,14 @@ import android.widget.EditText;
|
||||
|
||||
class HexEdit {
|
||||
|
||||
private static InputFilter[] withoutAlphaDigits = {new ColorPasteLengthFilter()};
|
||||
private static InputFilter[] withAlphaDigits = {new InputFilter.LengthFilter(8)};
|
||||
private static InputFilter[] withoutAlphaDigits = {
|
||||
new ColorPasteLengthFilter(),
|
||||
new HexFilter()
|
||||
};
|
||||
private static InputFilter[] withAlphaDigits = {
|
||||
new InputFilter.LengthFilter(8),
|
||||
new HexFilter()
|
||||
};
|
||||
|
||||
public static void setUpListeners(final EditText hexEdit, final ObservableColor observableColor) {
|
||||
|
||||
@@ -93,4 +99,19 @@ class HexEdit {
|
||||
}
|
||||
}
|
||||
|
||||
private static class HexFilter implements InputFilter {
|
||||
|
||||
@Override
|
||||
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
var state = true;
|
||||
for (int i = start; i < end; i++) {
|
||||
char ch = source.charAt(i);
|
||||
if (ch < '0' || ch> '9' && ch < 'A' || ch > 'F' && ch < 'a' || ch > 'f') {
|
||||
state = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return state ? source.subSequence(start, end) : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ThemesUtils {
|
||||
|
||||
public static int getAccentColor() {
|
||||
var accent = AndroidUtils.getPreferences().getInt("accent_color", getColorFromAttr(R.attr.accent));
|
||||
return (accent == 0 || isMonetTheme() || !isMilkshake()) ? getColorFromAttr(R.attr.accent) : accent;
|
||||
return (accent == 0 || !isMilkshake()) ? isMonetTheme() ? getColorFromAttr(R.attr.accent) : getStockAccent() : accent;
|
||||
} // Color accent
|
||||
|
||||
public static int getMutedAccentColor() {
|
||||
@@ -194,7 +194,7 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static int getMutedColor(int color) {
|
||||
return ColorUtils.blendARGB(color, (isDarkTheme() ? Color.BLACK : Color.WHITE), (isMilkshake() ? 0.5f : 0.3f));
|
||||
return ColorUtils.blendARGB(color, (isDarkTheme() ? Color.BLACK : Color.WHITE), (isMilkshake() ? 0.5f : 0.32f));
|
||||
}
|
||||
|
||||
public static void setCustomAccentColor(int newColor, boolean async) {
|
||||
@@ -239,6 +239,14 @@ public class ThemesUtils {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
}
|
||||
|
||||
public static int getStockAccent() {
|
||||
if (isMilkshake()) {
|
||||
return isDarkTheme() ? Color.parseColor("#71aaeb") : Color.parseColor("#3f8ae0");
|
||||
} else {
|
||||
return isDarkTheme() ? Color.parseColor("#71aaeb") : Color.parseColor("#528bcc");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDarkThemeRes() {
|
||||
if (isMonetTheme()) {
|
||||
if (isAmoledTheme()) {
|
||||
@@ -377,12 +385,14 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static void setStatusBarColor(Window window) {
|
||||
if (isDarkTheme()) {
|
||||
View view = window.getDecorView();
|
||||
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else {
|
||||
View view = window.getDecorView();
|
||||
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (isDarkTheme()) {
|
||||
View view = window.getDecorView();
|
||||
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else {
|
||||
View view = window.getDecorView();
|
||||
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -829,26 +829,13 @@
|
||||
|
||||
move-result p2
|
||||
|
||||
invoke-virtual {p0}, Landroidx/fragment/app/Fragment;->getResources()Landroid/content/res/Resources;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAccentColor()I
|
||||
|
||||
move-result v0
|
||||
|
||||
invoke-virtual {p1, p2, v0}, Lcom/google/android/material/tabs/TabLayout;->a(II)V
|
||||
|
||||
.line 11
|
||||
invoke-virtual {p0}, Landroidx/fragment/app/Fragment;->getResources()Landroid/content/res/Resources;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
invoke-virtual {p2, v1}, Landroid/content/res/Resources;->getColor(I)I
|
||||
|
||||
move-result p2
|
||||
|
||||
invoke-virtual {p1, p2}, Lcom/google/android/material/tabs/TabLayout;->setSelectedTabIndicatorColor(I)V
|
||||
invoke-virtual {p1, v0}, Lcom/google/android/material/tabs/TabLayout;->setSelectedTabIndicatorColor(I)V
|
||||
|
||||
.line 12
|
||||
:cond_0
|
||||
|
||||
Reference in New Issue
Block a user