Compare commits

...
Author SHA1 Message Date
Vologhat 235b287a36 fix telegram stickers notification crash 2022-10-18 16:14:47 +03:00
Vologhat 9317e86d66 Update build.gradle 2022-10-15 21:46:21 +03:00
aliveoutside 23f1b6c26b load ffmpeg-kit directly from libs folder via System.loadLibrary
add arm64 libs
2022-10-15 21:43:03 +03:00
aliveoutside a7d50bca26 remove ffmpeg libs from assets 2022-10-15 21:40:23 +03:00
aliveoutside 92fbd071de reduce ffmpeg-kit size 2022-10-15 21:12:56 +03:00
Vologhat b7860b857f Updated arm32-v7a libs 2022-10-15 20:20:36 +03:00
Vologhat cd0914041d arm64-v8a support 2022-10-15 15:05:41 +03:00
Vologhat 9f0230d935 Update R.java 2022-10-14 22:19:38 +03:00
Vologhat a05865c6a8 Added R.java generator and executing scripts 2022-10-14 22:14:56 +03:00
54 changed files with 117 additions and 34 deletions
+1 -3
View File
@@ -91,8 +91,6 @@ android {
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.preference:preference:1.2.0'
implementation fileTree(dir: 'libs', include: ['*.aar'])
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
}
}
@@ -12,7 +12,8 @@ import androidx.core.app.NotificationManagerCompat;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vtosters.lite.R;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import ru.vtosters.lite.utils.AndroidUtils;
@@ -21,22 +22,22 @@ import ru.vtosters.lite.utils.AndroidUtils;
* Created by Aefyr on 20.05.2018.
*/
public class NotificationsHelper {
private static final int NOTIFICATION_ID_BASE = 3921337;
// private static final int NOTIFICATION_ID_BASE = 3921337;
private static final String NOTIFICATION_CHANNEL_ID = "tgss_chan_v5";
private static final int MAX_UPDATE_NOTIFICATIONS_PER_SECOND = 3;
private static final int MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS = 1000 / MAX_UPDATE_NOTIFICATIONS_PER_SECOND;
private final HashMap<TelegramStickersPack, Integer> downloadingPacksNotificationsIds;
private final List<Integer> downloadingPacksNotificationsIds;
private final Context c;
private final NotificationManagerCompat manager;
private final AtomicLong lastNotificationTime = new AtomicLong(0);
private int currentNotificationN = 0;
// private int currentNotificationN = 0;
public NotificationsHelper(Context c) {
this.c = c;
manager = NotificationManagerCompat.from(c);
downloadingPacksNotificationsIds = new HashMap<>();
downloadingPacksNotificationsIds = new ArrayList<>();
if (oreo()) {
NotificationChannel notificationChan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, AndroidUtils.getString(R.string.telegram_stickers_service), NotificationManager.IMPORTANCE_HIGH);
@@ -45,19 +46,19 @@ public class NotificationsHelper {
}
public void packStartedDownloading(TelegramStickersPack pack) {
int notificationId = NOTIFICATION_ID_BASE + currentNotificationN++;
downloadingPacksNotificationsIds.put(pack, notificationId);
downloadingPacksNotificationsIds.add(pack.hash);
Notification.Builder builder = commonBuilder();
builder.setContentTitle(pack.state == TelegramStickersPack.DOWNLOADING ? pack.title + AndroidUtils.getString(R.string.telegram_stickers_downloading) : pack.title + AndroidUtils.getString(R.string.telegram_stickers_updating));
builder.setContentText(AndroidUtils.getString(R.string.telegram_stickers_gettinginfo));
builder.setOngoing(true);
manager.notify(notificationId, builder.build());
manager.notify(pack.hash, builder.build());
}
public void packDownloadUpdated(TelegramStickersPack pack, int downloadProgress) {
if (System.currentTimeMillis() - lastNotificationTime.get() < MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS)
if (System.currentTimeMillis() - lastNotificationTime.get() < MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS
|| !downloadingPacksNotificationsIds.contains(pack.hash))
return;
lastNotificationTime.set(System.currentTimeMillis());
@@ -69,11 +70,13 @@ public class NotificationsHelper {
builder.setOngoing(true);
builder.setOnlyAlertOnce(true);
if (downloadingPacksNotificationsIds.containsKey(pack))
manager.notify(downloadingPacksNotificationsIds.get(pack), builder.build());
manager.notify(pack.hash, builder.build());
}
public void packDoneDownloading(TelegramStickersPack pack, boolean success, boolean wasUpdate, @Nullable Exception e) {
if (!downloadingPacksNotificationsIds.remove(pack.hash))
return;
Notification.Builder builder = commonBuilder();
builder.setProgress(0, 0, false);
builder.setOngoing(false);
@@ -91,11 +94,12 @@ public class NotificationsHelper {
builder.setContentText(String.format(text, pack.title));
manager.notify(downloadingPacksNotificationsIds.remove(pack), builder.build());
manager.notify(pack.hash, builder.build());
}
public void removePackNotification(TelegramStickersPack pack) {
manager.cancel(downloadingPacksNotificationsIds.remove(pack));
if (downloadingPacksNotificationsIds.remove(pack.hash))
manager.cancel(pack.hash);
}
private Notification.Builder commonBuilder() {
@@ -32,11 +32,14 @@ public class TelegramStickersPack extends CustomStickersPack {
public int stickersCount = -1;
public String version;
public int index = -1;
public Integer hash;
public HashMap<String, List<Integer>> emojis = new HashMap<>();
public TelegramStickersPack(String id) {
this.id = id.toLowerCase();
final var idLowerCase = id.toLowerCase();
this.id = idLowerCase;
this.hash = idLowerCase.hashCode();
title = id;
}
@@ -106,7 +109,7 @@ public class TelegramStickersPack extends CustomStickersPack {
@Override
public int hashCode() {
return id.toLowerCase().hashCode();
return hash;
}
@Override
@@ -235,7 +235,7 @@ public class TelegramStickersService {
runOnUiThread(() -> {
newPack.state = TelegramStickersPack.DOWNLOADED;
notifyPackChanged(newPack, packs.indexOf(newPack));
currentlyDownloading.remove(newPack.id.toLowerCase());
currentlyDownloading.remove(newPack.id);
syncPack(newPack);
if (isUpdate) {
@@ -8,29 +8,24 @@ import com.arthenica.smartexception.java.Exceptions;
import java.util.Collections;
import java.util.List;
import ru.vtosters.lite.utils.AndroidUtils;
public class NativeLoader {
static final String[] FFMPEG_LIBRARIES = {"avutil", "swscale", "swresample", "avcodec", "avformat", "avfilter", "avdevice"};
static final String[] FFMPEG_LIBRARIES = {"avutil", "swresample", "avcodec", "avformat", "avfilter", "avdevice"};
private static void loadLibrary(String libraryName) {
String path = AndroidUtils.getGlobalContext().getFilesDir() + "/lib" + libraryName + ".so";
System.load(path);
System.loadLibrary(libraryName);
}
private static List<String> loadExternalLibraries() {
// return Packages.getExternalLibraries();
//return Packages.getExternalLibraries();
return Collections.emptyList();
}
private static String loadNativeAbi() {
// return AbiDetect.getNativeAbi();
return Abi.ABI_ARMV7A_NEON.getName();
return AbiDetect.getNativeAbi();
}
static String loadAbi() {
// return AbiDetect.getAbi();
return Abi.ABI_ARMV7A_NEON.getName();
return AbiDetect.getAbi();
}
static String loadPackageName() {
+15 -1
View File
@@ -1,6 +1,7 @@
package com.vtosters.lite;
public class R {
public final class R {
public static final class anim {
public static final int abc_fade_in = 0x7f010000; // 2130771968
public static final int abc_fade_out = 0x7f010001; // 2130771969
@@ -220,6 +221,8 @@ public class R {
public static final int targetlang_value = 0x7f030074; // 2130903156
public static final int undel_value = 0x7f030075; // 2130903157
public static final int wallpaper_change_dialog = 0x7f030076; // 2130903158
public static final int theme_type_name = 0x7f030077; // 2130903159
public static final int theme_type_name_checkbox = 0x7f030078; // 2130903160
}
public static final class attr {
@@ -19514,6 +19517,17 @@ public class R {
public static final int whitelisted_filters_groups_title = 0x7f121838; // 2131892280
public static final int why_news_not_updated_summ = 0x7f121839; // 2131892281
public static final int why_news_not_updated_title = 0x7f12183a; // 2131892282
public static final int blockminiapps_summ = 0x7f12183b; // 2131892283
public static final int blockminiapps_title = 0x7f12183c; // 2131892284
public static final int current_theme = 0x7f12183d; // 2131892285
public static final int invalid_pack_link = 0x7f12183e; // 2131892286
public static final int maxquality_summ = 0x7f12183f; // 2131892287
public static final int maxquality_title = 0x7f121840; // 2131892288
public static final int newsfeed_notif_summ = 0x7f121841; // 2131892289
public static final int newsfeed_notif_title = 0x7f121842; // 2131892290
public static final int promotedstickers_title = 0x7f121843; // 2131892291
public static final int vkx_integration_enabled_info = 0x7f121844; // 2131892292
public static final int writebar_ios_title = 0x7f121845; // 2131892293
}
public static final class style {
@@ -28,15 +28,13 @@ public class FFMpeg {
* @return True if success, else false
*/
public static boolean convert(File in, String out, MusicTrack track) {
checkFFMpegLibs();
// convert .ts file to .mp3 file via ffmpeg
var sb = new StringBuilder();
sb.append("-y -i \"").append(in.getAbsolutePath()).append("\"");
sb.append(" -map 0 -dn ");
sb.append(" -loglevel error");
sb.append(" -hide_banner");
//sb.append(" -loglevel error");
//sb.append(" -hide_banner");
sb.append(" -write_id3v2 1");
String title = null;
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
@echo off
cd scripts
echo.
echo Decompile release APK...
echo.
call java -jar apktool.jar d VTLite.apk -f -o tmp -s --use-aapt2 -p ../scripts/framework/
if "%ERRORLEVEL%" == "0" (
echo %ESC%[92mSuccessful%ESC%[0m
) else (
echo %ESC%[31mFailed%ESC%[0m
exit /B 1
)
echo.
echo Generate R.java
echo.
call java -jar rclass-generator.jar -f tmp/res/values/public.xml -o ..\app\src\main\java\com\vtosters\lite\R.java -p com.vtosters.lite --comments
if "%ERRORLEVEL%" == "0" (
echo %ESC%[92mSuccessful%ESC%[0m
) else (
echo %ESC%[31mFailed%ESC%[0m
exit /B 1
)
echo.
echo Clean temp dir
echo.
call rmdir /s/q tmp
if "%ERRORLEVEL%" == "0" (
echo %ESC%[92mSuccessful%ESC%[0m
) else (
echo %ESC%[31mFailed%ESC%[0m
exit /B 1
)
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
RED='\033[31m'
GREEN='\033[92m'
NC='\033[0m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
cd ../
echo -e "${BOLD}${UNDERLINE}Decompile release APK...${NC}\n"
java -jar ../scripts/apktool.jar d VTLite.apk -f -o tmp -s --use-aapt2 -p ../scripts/framework/
if [ $? -eq 0 ]; then
echo -e "${GREEN}Успех!${NC}\n"
else
echo -e "${RED}Провал.${NC}\n"
exit 1
fi
echo -e "${BOLD}${UNDERLINE}Regenerate R.java file...${NC}\n"
java -jar ../scripts/rclass-generator.jar -f ../scripts/tmp/res/values/public.xml -o ../scripts/app/src/main/java/com/vtosters/lite/R.java -p com.vtosters.lite --comments
if [ $? -eq 0 ]; then
echo -e "${GREEN}Успех!${NC}\n"
else
echo -e "${RED}Провал.${NC}\n"
exit 1
fi
echo -e "${BOLD}${UNDERLINE}Clean temp dir...${NC}\n"
rm -rf ../scripts/tmp
if [ $? -eq 0 ]; then
echo -e "${GREEN}Успех!${NC}\n"
else
echo -e "${RED}Провал.${NC}\n"
exit 1
fi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.