Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b3896f4ca | ||
|
|
fc9ccf66d1 | ||
|
|
d205f2894b | ||
|
|
7afc04b2b2 | ||
|
|
584ee96ee0 | ||
|
|
66f7ea1b79 | ||
|
|
7b0a83458b |
@@ -37,7 +37,7 @@
|
||||
|
||||
* Стабильные сборки находятся в [Releases](https://github.com/vtosters/lite/releases)
|
||||
|
||||
Зеркало на нашем [<img src="https://gitea.com/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/gdlbo/lite)
|
||||
Зеркало на нашем [<img src="https://gitea.com/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/vtosters/lite)
|
||||
|
||||
### Быстрая навигация
|
||||
|
||||
|
||||
@@ -36,10 +36,8 @@ public class TelegramStickersPack extends CustomStickersPack {
|
||||
public HashMap<String, List<Integer>> emojis = new HashMap<>();
|
||||
|
||||
public TelegramStickersPack(String id) {
|
||||
final var idLowerCase = id.toLowerCase();
|
||||
this.id = idLowerCase;
|
||||
this.hash = idLowerCase.hashCode();
|
||||
title = id;
|
||||
this.id=this.title=id;
|
||||
this.hash=id.hashCode();
|
||||
}
|
||||
|
||||
public JSONObject encodeEmojis() throws JSONException {
|
||||
@@ -103,7 +101,7 @@ public class TelegramStickersPack extends CustomStickersPack {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equalsIgnoreCase(id);
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equals(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.util.Log;
|
||||
import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo;
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
|
||||
import java.io.File;
|
||||
@@ -152,6 +153,7 @@ public class TelegramStickersService {
|
||||
|
||||
private void notifyActivePacksListChanged() {
|
||||
getGlobalContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getGlobalContext().sendBroadcast(new Intent(VTSettings.ACTION_INVALIDATE_TGS_COUNT));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -222,7 +224,7 @@ public class TelegramStickersService {
|
||||
final TelegramStickersPack newPack = pack;
|
||||
final boolean isUpdate = update;
|
||||
|
||||
currentlyDownloading.add(id.toLowerCase());
|
||||
currentlyDownloading.add(id);
|
||||
notificationsHelper.packStartedDownloading(newPack);
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import b.h.g.k.VKProgressDialog;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
@@ -65,6 +66,8 @@ public class MainActivityInjector {
|
||||
InstallGMS.alert(activity);
|
||||
DisableBattery.alert(activity);
|
||||
// VKIDProtection.alert(activity);
|
||||
//needs to show selected tgs pack count in settings after cold launch
|
||||
TelegramStickersService.getInstance(activity);
|
||||
}
|
||||
|
||||
private static void updateBinsAndTmpArchive(Activity activity) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class VKUIHook {
|
||||
}
|
||||
|
||||
private static void applyVKUIStyles(WebView webView) {
|
||||
if (getBoolValue("VKUI_INJ", true) && !webView.getUrl().contains("static.vk.com/memories")) {
|
||||
if (getBoolValue("VKUI_INJ", true) && webView != null && webView.getUrl() != null && !webView.getUrl().contains("static.vk.com/memories")) {
|
||||
if (!WebViewColoringUtils.isLoaded) {
|
||||
WebViewColoringUtils.load();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ThemesHacks {
|
||||
}
|
||||
|
||||
public static int getHackedColor(@NonNull Context context, @ColorRes int color) {
|
||||
if (ThemesUtils.isMonetTheme()) {
|
||||
if (ThemesUtils.isMonetTheme() || ThemesManager.canApplyCustomAccent()) {
|
||||
if (Preferences.getBoolValue("logColors", false)) {
|
||||
try {
|
||||
Log.d("ThemesCore", "Requesting color by color " + context.getResources().getResourceName(color));
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.TextView;
|
||||
import com.vk.core.drawable.RecoloredDrawable;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.themes.ColorReferences;
|
||||
import ru.vtosters.lite.themes.ThemesManager;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class RecolorUtils {
|
||||
@@ -43,7 +44,7 @@ public class RecolorUtils {
|
||||
}
|
||||
|
||||
public static int recolorHexColor(int i) {
|
||||
if (!ThemesUtils.isMonetTheme()) return i;
|
||||
if (!ThemesUtils.isMonetTheme() || !ThemesManager.canApplyCustomAccent()) return i;
|
||||
var accented = ColorReferences.isAccentedColor(i);
|
||||
var mutedaccented = ColorReferences.isMutedAccentedColor(i);
|
||||
return (accented || mutedaccented) ? (accented ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : i;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -28,6 +29,7 @@ import ru.vtosters.hooks.SwitchHook;
|
||||
import ru.vtosters.lite.tgs.TGPref;
|
||||
import ru.vtosters.lite.tgs.TGRoot;
|
||||
import ru.vtosters.lite.ui.components.IItemMovingListener;
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -138,7 +140,11 @@ public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.
|
||||
});
|
||||
mName.setText(pack.title);
|
||||
mSwitch.setChecked(pack.enabled);
|
||||
mSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> sService.setPackEnabled(pack, isChecked, true));
|
||||
mSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
sService.setPackEnabled(pack, isChecked, false);
|
||||
buttonView.getContext().sendBroadcast(new Intent(VTSettings.ACTION_INVALIDATE_TGS_COUNT));
|
||||
});
|
||||
|
||||
mStickersCount.setText(pack.stickersCount + " " + mStickersCount.getContext().getString(R.string.stickerscount));
|
||||
|
||||
SwitchHook.setSwitchCompatColors(mSwitch, mSwitch.getContext());
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.preference.Preference;
|
||||
import com.aefyr.tsg.g2.TelegramStickersPack;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.about.AboutAppFragment;
|
||||
import com.vk.balance.BalanceFragment;
|
||||
@@ -42,7 +44,19 @@ import ru.vtosters.lite.utils.*;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class VTSettings extends TrackedMaterialPreferenceToolbarFragment implements TelegramStickersService.StickersEventsListener {
|
||||
public class VTSettings extends TrackedMaterialPreferenceToolbarFragment {
|
||||
|
||||
final static public String ACTION_INVALIDATE_TGS_COUNT="com.vtosters.lite.intent.action.INVALIDATE_TGS_COUNT";
|
||||
|
||||
final BroadcastReceiver mTgsReceiver=new BroadcastReceiver()
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
if(ACTION_INVALIDATE_TGS_COUNT.equals(intent.getAction()))
|
||||
findPreference("tgs_stickers").setSummary(getTGSsumm());
|
||||
}
|
||||
};
|
||||
|
||||
public static String getValAsString(@StringRes int strRes, Boolean value) {
|
||||
if (value) {
|
||||
@@ -76,42 +90,12 @@ public class VTSettings extends TrackedMaterialPreferenceToolbarFragment impleme
|
||||
ThemesUtils.setTheme(isDarkTheme ? ThemesUtils.getDarkTheme() : ThemesUtils.getLightTheme(), requireActivity(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackAdded(TelegramStickersPack pack, int atIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackRemoved(TelegramStickersPack pack, int atIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackChanged(TelegramStickersPack pack, int atIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackDownloadError(TelegramStickersPack pack, Exception error) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivePacksListChanged() {
|
||||
findPreference("tgs_stickers").setSummary(getTGSsumm());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInactivePacksListChanged() {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
TelegramStickersService.getInstance(requireContext()).addStickersEventsListener(this);
|
||||
requireContext().registerReceiver(mTgsReceiver,new IntentFilter(ACTION_INVALIDATE_TGS_COUNT));
|
||||
|
||||
this.addPreferencesFromResource(R.xml.empty);
|
||||
|
||||
@@ -590,18 +574,14 @@ public class VTSettings extends TrackedMaterialPreferenceToolbarFragment impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onDestroy()
|
||||
{
|
||||
requireContext().unregisterReceiver(mTgsReceiver);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int T4() {
|
||||
return R.string.notification_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
TelegramStickersService.getInstance(requireContext()).removeStickersEventsListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
+162
-169
@@ -20,7 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
@@ -36,55 +35,58 @@ import java.io.File;
|
||||
public class StickersFragment extends BaseToolbarFragment {
|
||||
public final static String ACTION_RELOAD = "com.vtosters.lite.action.RELOAD_TGS_LIST";
|
||||
|
||||
private final static int TYPE_DIRECT = 0, TYPE_SOCKS = 2;
|
||||
public int from;
|
||||
public int to;
|
||||
private TelegramStickersGrabber mGrabber;
|
||||
private TelegramStickersService mService;
|
||||
private StickerPackAdapter mAdapter;
|
||||
private boolean movePending = false;
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
final static int TYPE_DIRECT = 0;
|
||||
final static int TYPE_SOCKS = 2;
|
||||
|
||||
TelegramStickersGrabber mGrabber;
|
||||
StickerPackAdapter mAdapter;
|
||||
boolean movePending = false;
|
||||
int from,to;
|
||||
final BroadcastReceiver mReceiver=new BroadcastReceiver() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ACTION_RELOAD)) {
|
||||
if (mAdapter != null) {
|
||||
try {
|
||||
if (movePending) {
|
||||
movePending = false;
|
||||
mAdapter.notifyItemMoved(from, to);
|
||||
from = -1;
|
||||
to = -1;
|
||||
} else {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!intent.getAction().equals(ACTION_RELOAD)||mAdapter==null)return;
|
||||
try
|
||||
{
|
||||
if(movePending)
|
||||
{
|
||||
movePending=false;
|
||||
mAdapter.notifyItemMoved(from, to);
|
||||
from=to=-1;
|
||||
}
|
||||
else mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
catch(Exception e)
|
||||
{ e.printStackTrace(); }
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreateMenu(Menu menu) {
|
||||
MenuItem item = menu.add(0, 0, 0, "");
|
||||
item.setIcon(ThemesUtils.recolorDrawable(AndroidUtils.getGlobalContext().getDrawable(R.drawable.ic_settings_outline_28)))
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
protected void onCreateMenu(Menu menu)
|
||||
{
|
||||
menu.add(0, 0, 0, "")
|
||||
.setIcon(ThemesUtils.recolorDrawable(requireContext().getDrawable(R.drawable.ic_add_outline_28)))
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
menu.add(0,1,0,"")
|
||||
.setIcon(R.drawable.ic_settings_outline_28)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
super.onCreateMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem arg0) {
|
||||
openMenu(null);
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
switch (item.getItemId())
|
||||
{
|
||||
case 0 -> addTgsPack();
|
||||
case 1 -> openMenu(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openMenu(String toast) {
|
||||
if (toast != null) {
|
||||
Toast.makeText(requireContext(), toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if(toast!=null)Toast.makeText(requireContext(),toast,Toast.LENGTH_SHORT).show();
|
||||
NavigatorUtils.switchFragment(requireContext(), StickersPreferencesFragment.class);
|
||||
}
|
||||
|
||||
@@ -93,41 +95,29 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
requireContext().registerReceiver(mReceiver, new IntentFilter(ACTION_RELOAD));
|
||||
|
||||
mGrabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
|
||||
mService = TelegramStickersService.getInstance(requireContext());
|
||||
mGrabber=new TelegramStickersGrabber(TGPref.getTGBotKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateContent(@NonNull LayoutInflater inflater, @Nullable Bundle bundle) {
|
||||
setTitle(R.string.vtltgs);
|
||||
|
||||
FrameLayout layout = new FrameLayout(requireContext());
|
||||
final var container=new FrameLayout(requireContext());
|
||||
final var recycler=new RecyclerView(requireContext());
|
||||
|
||||
mAdapter = new StickerPackAdapter();
|
||||
RecyclerView mRecycler = new RecyclerView(requireContext());
|
||||
mAdapter=new StickerPackAdapter();
|
||||
recycler.setAdapter(mAdapter);
|
||||
|
||||
StickerTouchHelperCallback callback = new StickerTouchHelperCallback(mAdapter);
|
||||
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
|
||||
touchHelper.attachToRecyclerView(mRecycler);
|
||||
final var callback=new StickerTouchHelperCallback(mAdapter);
|
||||
final var touchHelper=new ItemTouchHelper(callback);
|
||||
touchHelper.attachToRecyclerView(recycler);
|
||||
|
||||
mRecycler.setAdapter(mAdapter);
|
||||
mRecycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
||||
layout.addView(mRecycler, new ViewGroup.LayoutParams(-1, -1));
|
||||
recycler.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
|
||||
container.addView(recycler,new ViewGroup.LayoutParams(-1,-1));
|
||||
|
||||
FloatingActionButton mAddStickerPack = new FloatingActionButton(requireContext());
|
||||
mAddStickerPack.setImageResource(R.drawable.ic_add_24);
|
||||
mAddStickerPack.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
mAddStickerPack.setOnClickListener(v2 -> fabClick());
|
||||
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
|
||||
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||
params.setMargins(0, 0, 0, AndroidUtils.dp2px(12f));
|
||||
layout.addView(mAddStickerPack, params);
|
||||
|
||||
return layout;
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View arg0, Bundle arg1) {
|
||||
super.onViewCreated(arg0, arg1);
|
||||
@@ -139,70 +129,79 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
requireContext().unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
private void fabClick() {
|
||||
int method = TGPref.getTGConnectMethod();
|
||||
if (method == -1) {
|
||||
openMenu(requireContext().getString(R.string.stickersconnection));
|
||||
return;
|
||||
}
|
||||
private void addTgsPack()
|
||||
{
|
||||
final var method=TGPref.getTGConnectMethod();
|
||||
if(method!=-1)
|
||||
{
|
||||
initGrabber();
|
||||
switch(method)
|
||||
{
|
||||
case TYPE_SOCKS ->
|
||||
{
|
||||
if (TGPref.getTGProxyIP()==null)openMenu(requireContext().getString(R.string.stickersproxy1));
|
||||
}
|
||||
case TYPE_DIRECT ->
|
||||
{
|
||||
initGrabber();
|
||||
final Runnable lambda = () ->
|
||||
{
|
||||
final var container=new LinearLayout(requireContext());
|
||||
|
||||
initGrabber();
|
||||
if (method == TYPE_SOCKS) {
|
||||
if (TGPref.getTGProxyIP() == null) {
|
||||
openMenu(requireContext().getString(R.string.stickersproxy1));
|
||||
final var input=new EditText(requireContext());
|
||||
final var inputLP = new ViewGroup.MarginLayoutParams(-1,-2);
|
||||
inputLP.setMargins(
|
||||
AndroidUtils.dp2px(24.f),
|
||||
0,
|
||||
AndroidUtils.dp2px(24.f),
|
||||
0);
|
||||
container.addView(input,inputLP);
|
||||
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.stickershelp1)
|
||||
// .setMessage(R.string.stickershelp2)
|
||||
.setView(container)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) ->
|
||||
{
|
||||
var packId=input.getText().toString();
|
||||
if (packId.startsWith("https://"))
|
||||
packId=packId.substring(packId.lastIndexOf('/')+1);
|
||||
TelegramStickersService.getInstance(requireContext())
|
||||
.requestPackDownload(
|
||||
packId,
|
||||
new File(requireContext().getFilesDir(),"VT-Stickers/"+packId));
|
||||
})
|
||||
.setNeutralButton(android.R.string.cancel,(dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
};
|
||||
|
||||
if(TGPref.getTGBotKey()==null)enterBotKey(() -> checkApiKey(lambda));
|
||||
else checkApiKey(lambda);
|
||||
}
|
||||
}
|
||||
} else if (method == TYPE_DIRECT) {
|
||||
final Runnable callback = () -> {
|
||||
LinearLayout linearLayout = new LinearLayout(requireContext());
|
||||
|
||||
final EditText editText = new EditText(requireContext());
|
||||
editText.setHintTextColor(ThemesUtils.getSTextAttr());
|
||||
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
|
||||
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickershelp1))
|
||||
.setMessage(requireContext().getString(R.string.stickershelp2))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String pack = editText.getText().toString();
|
||||
if (!pack.startsWith("https://")) {
|
||||
pack = "https://" + pack;
|
||||
} else if (!pack.contains("addstickers")) {
|
||||
AndroidUtils.sendToast(AndroidUtils.getString("invalid_pack_link"));
|
||||
}
|
||||
pack = parsePack(pack);
|
||||
mService.requestPackDownload(pack, new File(requireContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
})
|
||||
.setNeutralButton(android.R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
)
|
||||
.show();
|
||||
};
|
||||
if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(callback));
|
||||
else checkApiKey(callback);
|
||||
}
|
||||
else openMenu(requireContext().getString(R.string.stickersconnection));
|
||||
}
|
||||
|
||||
private void initGrabber() {
|
||||
int method = TGPref.getTGConnectMethod();
|
||||
if (method == TYPE_DIRECT) {
|
||||
TelegramStickersGrabber.USE_PROXY = false;
|
||||
mGrabber.resetProxy();
|
||||
} else if (method == TYPE_SOCKS) {
|
||||
if (TGPref.getTGProxyIP() != null) {
|
||||
TelegramStickersGrabber.USE_PROXY = true;
|
||||
TelegramStickersGrabber.PROXY_IP = TGPref.getTGProxyIP();
|
||||
TelegramStickersGrabber.PROXY_PORT = TGPref.getTGProxyPort();
|
||||
if (TGPref.isTGProxyPassEnabled()) {
|
||||
TelegramStickersGrabber.HAS_PASS = true;
|
||||
TelegramStickersGrabber.PROXY_USER = TGPref.getTGProxyUser();
|
||||
TelegramStickersGrabber.PROXY_PASS = TGPref.getTGProxyPass();
|
||||
switch(TGPref.getTGConnectMethod())
|
||||
{
|
||||
case TYPE_DIRECT ->
|
||||
{
|
||||
TelegramStickersGrabber.USE_PROXY=false;
|
||||
mGrabber.resetProxy();
|
||||
}
|
||||
case TYPE_SOCKS ->
|
||||
{
|
||||
if(TGPref.getTGProxyIP()==null)break;
|
||||
TelegramStickersGrabber.USE_PROXY=true;
|
||||
TelegramStickersGrabber.PROXY_IP=TGPref.getTGProxyIP();
|
||||
TelegramStickersGrabber.PROXY_PORT=TGPref.getTGProxyPort();
|
||||
if (TGPref.isTGProxyPassEnabled())
|
||||
{
|
||||
TelegramStickersGrabber.HAS_PASS=true;
|
||||
TelegramStickersGrabber.PROXY_USER=TGPref.getTGProxyUser();
|
||||
TelegramStickersGrabber.PROXY_PASS=TGPref.getTGProxyPass();
|
||||
}
|
||||
mGrabber.enableProxy();
|
||||
}
|
||||
@@ -210,42 +209,42 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
TelegramStickersGrabber.updateURLs();
|
||||
}
|
||||
|
||||
private void enterBotKey(Runnable r) {
|
||||
LinearLayout linearLayout = new LinearLayout(requireContext());
|
||||
private void enterBotKey(Runnable callback)
|
||||
{
|
||||
final var container=new LinearLayout(requireContext());
|
||||
|
||||
final EditText editText = new EditText(requireContext());
|
||||
editText.setHintTextColor(ThemesUtils.getSTextAttr());
|
||||
editText.setBackgroundTintList(ThemesUtils.getAccenedColorStateList());
|
||||
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
|
||||
margin.setMargins(AndroidUtils.dp2px(24f), 0, AndroidUtils.dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
final var input=new EditText(requireContext());
|
||||
final var inputLP=new ViewGroup.MarginLayoutParams(-1,-2);
|
||||
inputLP.setMargins(
|
||||
AndroidUtils.dp2px(24.f),
|
||||
0,
|
||||
AndroidUtils.dp2px(24.f),
|
||||
0);
|
||||
container.addView(input,inputLP);
|
||||
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickersapi5))
|
||||
.setMessage(requireContext().getString(R.string.stickersapi6))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
TGPref.setTGBotKey(editText.getText().toString());
|
||||
if (r != null) r.run();
|
||||
.setView(container)
|
||||
.setPositiveButton(android.R.string.ok,(dialog, which) ->
|
||||
{
|
||||
TGPref.setTGBotKey(input.getText().toString());
|
||||
if(callback!=null)callback.run();
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
)
|
||||
.setNegativeButton(android.R.string.cancel,(dialog, which) -> dialog.dismiss())
|
||||
.setNeutralButton(requireContext().getString(R.string.stickersapi7),
|
||||
(dialog, which) -> new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickersapi8))
|
||||
.setMessage(requireContext().getString(R.string.stickersapi9) +
|
||||
requireContext().getString(R.string.stickersapi10))
|
||||
.setNeutralButton(AndroidUtils.getString("open_bot"), (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()
|
||||
(dialog, which) ->
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setTitle(requireContext().getString(R.string.stickersapi8))
|
||||
.setMessage(requireContext().getString(R.string.stickersapi9) +
|
||||
requireContext().getString(R.string.stickersapi10))
|
||||
.setNeutralButton(AndroidUtils.getString("open_bot"),(dl, i) -> {
|
||||
final var intent=new Intent(Intent.ACTION_VIEW,Uri.parse("https://t.me/botfather"))
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
requireActivity().startActivity(intent);
|
||||
})
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
)
|
||||
.show();
|
||||
}
|
||||
@@ -253,45 +252,39 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
private void checkApiKey(Runnable callback) {
|
||||
mGrabber.setBotApiKey(TGPref.getTGBotKey());
|
||||
|
||||
var context = requireContext();
|
||||
final var dialog=new ProgressDialog(requireContext());
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
dialog.setMessage(requireContext().getString(R.string.stickersapi1));
|
||||
dialog.show();
|
||||
|
||||
final ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
progressDialog.setMessage(requireContext().getString(R.string.stickersapi1));
|
||||
progressDialog.show();
|
||||
|
||||
mGrabber.checkKey(new TelegramStickersGrabber.KeyCheckListener() {
|
||||
mGrabber.checkKey(new TelegramStickersGrabber.KeyCheckListener()
|
||||
{
|
||||
@Override
|
||||
public void onKeyChecked(boolean ok) {
|
||||
progressDialog.dismiss();
|
||||
if (!ok) {
|
||||
Toast.makeText(context, requireContext().getString(R.string.stickersapi2), Toast.LENGTH_SHORT).show();
|
||||
public void onKeyChecked(boolean ok)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if (!ok)
|
||||
{
|
||||
Toast.makeText(requireContext(), requireContext().getString(R.string.stickersapi2),Toast.LENGTH_SHORT).show();
|
||||
TGPref.setTGBotKey(null);
|
||||
return;
|
||||
}
|
||||
mService.setBotKey(TGPref.getTGBotKey());
|
||||
TelegramStickersService.getInstance(requireContext())
|
||||
.setBotKey(TGPref.getTGBotKey());
|
||||
|
||||
if (callback != null) callback.run();
|
||||
if (callback!=null)callback.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetError() {
|
||||
progressDialog.dismiss();
|
||||
new VkAlertDialog.Builder(context)
|
||||
public void onNetError()
|
||||
{
|
||||
dialog.dismiss();
|
||||
new VkAlertDialog.Builder(requireContext())
|
||||
.setMessage(requireContext().getString(R.string.stickersapi3))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(requireContext().getString(R.string.stickersapi4), (arg0, arg1) -> checkApiKey(callback))
|
||||
.setPositiveButton(requireContext().getString(R.string.stickersapi4),(di,which) -> checkApiKey(callback))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String parsePack(String pack) {
|
||||
if (pack.startsWith("https://t.me/addstickers/")) {
|
||||
pack = pack.substring(25);
|
||||
} else if (pack.startsWith("https://telegram.me/addstickers/")) {
|
||||
pack = pack.substring(32);
|
||||
}
|
||||
return pack;
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,7 @@ public class VTVerifications {
|
||||
.apply();
|
||||
isLoaded = true;
|
||||
Log.d("VTVerifications", "load from network");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception ignored) {
|
||||
if (prefs.contains("ids")) {
|
||||
parseJson(prefs.getString("ids", "[]"));
|
||||
Log.d("VTVerifications", "load from memory. Something went wrong with parsing");
|
||||
@@ -92,7 +91,7 @@ public class VTVerifications {
|
||||
processIds(json.optJSONArray("404"), sDevelopers);
|
||||
processIds(json.optJSONArray("1337"), sServiceAccounts);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +99,13 @@ public class VTVerifications {
|
||||
if (jsonIds == null || jsonIds.length() == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < jsonIds.length(); i++)
|
||||
member.add(jsonIds.optInt(i));
|
||||
for (int i = 0; i < jsonIds.length(); i++) {
|
||||
try {
|
||||
member.add(jsonIds.optInt(i));
|
||||
} catch (Exception ignored) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPrometheus(int id) {
|
||||
|
||||
Reference in New Issue
Block a user