Skip to content

Commit

Permalink
Confirmation before app quit
Browse files Browse the repository at this point in the history
  • Loading branch information
PoomSmart committed Nov 9, 2022
1 parent 99886fa commit a671db1
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET := iphone:clang:latest:11.0
INSTALL_TARGET_PROCESSES = YouTube
ARCHS = arm64
PACKAGE_VERSION = 1.4.4
PACKAGE_VERSION = 1.4.5

include $(THEOS)/makefiles/common.mk

Expand Down
40 changes: 27 additions & 13 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#define INCLUDED_CLASSES @"Included classes: YTGlobalConfig, YTColdConfig, YTHotConfig"
#define EXCLUDED_METHODS @"Excluded settings: android*, amsterdam*, musicClient* and unplugged*"

#define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil]
#define _LOC(b, x) [b localizedStringForKey:x value:nil table:nil]
#define LOC(x) _LOC(tweakBundle, x)

@interface YTSettingsSectionItemManager (YTABConfig)
- (void)updateYTABCSectionWithEntry:(id)entry;
Expand Down Expand Up @@ -152,6 +153,8 @@ static NSString *getCategory(char c, NSString *method) {
int totalSettings = 0;
NSBundle *tweakBundle = YTABCBundle();
BOOL isPhone = ![%c(YTCommonUtils) isIPad];
NSString *yesText = _LOC([NSBundle mainBundle], @"settings.yes");
NSString *cancelText = _LOC([NSBundle mainBundle], @"confirm.cancel");
if (tweakEnabled()) {
NSMutableDictionary <NSString *, NSMutableArray <YTSettingsSectionItem *> *> *properties = [NSMutableDictionary dictionary];
for (NSString *classKey in cache) {
Expand Down Expand Up @@ -257,13 +260,13 @@ static NSString *getCategory(char c, NSString *method) {
accessibilityIdentifier:nil
detailTextBlock:nil
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
for (NSString *key in [defaults dictionaryRepresentation].allKeys) {
if ([key hasPrefix:Prefix])
[defaults removeObjectForKey:key];
}
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
for (NSString *key in [defaults dictionaryRepresentation].allKeys) {
if ([key hasPrefix:Prefix])
[defaults removeObjectForKey:key];
}
exit(0);
} actionTitle:LOC(@"APPLY")];
} actionTitle:yesText];
alertView.title = LOC(@"WARNING");
alertView.subtitle = LOC(@"APPLY_DESC");
[alertView show];
Expand All @@ -276,10 +279,16 @@ static NSString *getCategory(char c, NSString *method) {
accessibilityIdentifier:nil
switchOn:groupedSettings()
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[defaults setBool:enabled forKey:GroupedKey];
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
exit(0);
} actionTitle:LOC(@"APPLY")];
YTAlertView *alertView = [%c(YTAlertView)
confirmationDialogWithAction:^{
[defaults setBool:enabled forKey:GroupedKey];
exit(0);
}
actionTitle:yesText
cancelAction:^{
[cell setSwitchOn:!enabled animated:YES];
}
cancelTitle:cancelText];
alertView.title = LOC(@"WARNING");
alertView.subtitle = LOC(@"APPLY_DESC");
[alertView show];
Expand All @@ -304,9 +313,14 @@ static NSString *getCategory(char c, NSString *method) {
switchOn:tweakEnabled()
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[defaults setBool:enabled forKey:EnabledKey];
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
exit(0);
} actionTitle:LOC(@"APPLY")];
YTAlertView *alertView = [%c(YTAlertView)
confirmationDialogWithAction:^{
exit(0);
} actionTitle:yesText
cancelAction:^{
[cell setSwitchOn:!enabled animated:YES];
}
cancelTitle:cancelText];
alertView.title = LOC(@"WARNING");
alertView.subtitle = LOC(@"APPLY_DESC");
[alertView show];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "التغييرات";
"TOTAL_MODIFIED_SETTINGS" = "المجموع: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "فتح موضوع المناقشات";
"OPEN_MEGATHREAD_DESC" = "فتح موضوع YTABConfig على موقع GitHub حيث يمكنك مشاركة ومناقشة تأثير تفعيل وإلغاء كل خيار.";
"SETTINGS_START_WITH" = "الإعدادات التي تبدأ بـ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "Änderungen";
"TOTAL_MODIFIED_SETTINGS" = "Total: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Megathread öffnen";
"OPEN_MEGATHREAD_DESC" = "Öffne den YTABConfig Megathread auf GitHub, in dem Sie sich über die Auswirkungen der Aktivierung bzw. Deaktivierung der einzelnen Einstellungen austauschen und diskutieren können.";
"SETTINGS_START_WITH" = "Einstellungen beginnend mit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
"MODIFIED_SETTINGS_TITLE" = "Changes";
"TOTAL_MODIFIED_SETTINGS" = "Total: %ld";

// Apply changes alert
// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "App will be closed to apply the changes";
"APPLY" = "Apply";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Open megathread";
"OPEN_MEGATHREAD_DESC" = "Open YTABConfig megathread on GitHub where you can share and discuss the effect of each flag being enabled or disabled.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "Változtatások";
"TOTAL_MODIFIED_SETTINGS" = "Teljes: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Megaszál megnyitása";
"OPEN_MEGATHREAD_DESC" = "Nyissa meg az YTABConfig megaszálat a GitHubon, ahol megoszthatja és megvitathatja az egyes jelzők engedélyezésének vagy letiltásának hatását.";
"SETTINGS_START_WITH" = "A következővel kezdődő beállítások:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "変更点";
"TOTAL_MODIFIED_SETTINGS" = "合計: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "メガスレッドを開きます";
"OPEN_MEGATHREAD_DESC" = "各フラグの有効,無効の効果を共有,議論できるGitHubのYTABConfig メガスレッドを開きます";
"SETTINGS_START_WITH" = "から始まる設定";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "변경 사항";
"TOTAL_MODIFIED_SETTINGS" = "총합: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "메가스레드 열기";
"OPEN_MEGATHREAD_DESC" = "GitHub에서 YTABConfig 메가스레드를 열어 각 플래그가 활성화 또는 비활성화되는 효과를 공유하고 논의할 수 있습니다.";
"SETTINGS_START_WITH" = "다음 글자로 시작하는 설정들 : ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "Mudanças";
"TOTAL_MODIFIED_SETTINGS" = "Total: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Abrir discussão";
"OPEN_MEGATHREAD_DESC" = "Abre a discussão do YTABConfig no GitHub, onde você pode compartilhar e discutir o efeito de cada sinalizador(flag) sendo habilitado ou desabilitado.";
"SETTINGS_START_WITH" = "Configurações começando com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
"MODIFIED_SETTINGS_TITLE" = "Настройки";
"TOTAL_MODIFIED_SETTINGS" = "Всего: %ld";

// Apply changes alert
// Quit app alert
"WARNING" = "Внимание";
"APPLY_DESC" = "Приложение будет закрыто для применения настроек";
"APPLY" = "Применить";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Дискуссии и рекомендации";
"OPEN_MEGATHREAD_DESC" = "Перенаправит вас на страницу дискуссий и рекомендаций по YTABConfig на GitHub, где вы можете обсудить настройки и поделиться своим опытом о настройках твика.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "Değişiklikler";
"TOTAL_MODIFIED_SETTINGS" = "Toplam: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Open megathread";
"OPEN_MEGATHREAD_DESC" = "Etkinleştirilen veya devre dışı bırakılan her ayarın etkisini paylaşabileceğiniz ve tartışabileceğiniz YTABConfig megabaşlığını(megathread) GitHub'da açar.";
"SETTINGS_START_WITH" = "Yazılan ile başlayan ayarlar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "Các thay đổi";
"TOTAL_MODIFIED_SETTINGS" = "Tổng cộng: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "Mở megathread";
"OPEN_MEGATHREAD_DESC" = "Mở megathread của YTABConfig trên Github, nơi bạn có thể chia sẻ và thảo luận về công dụng của các flag khi bật/tắt.";
"SETTINGS_START_WITH" = "Các flag bắt đầu với vần";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"MODIFIED_SETTINGS_TITLE" = "已變更的";
"TOTAL_MODIFIED_SETTINGS" = "總共: %ld";

// Quit app alert
"WARNING" = "Warning";
"APPLY_DESC" = "This action will quit YouTube. Are you sure you want to continue?";

"OPEN_MEGATHREAD" = "打開討論區";
"OPEN_MEGATHREAD_DESC" = "打開YTABConfig在GitHub上的討論區,您可以在此討論或分享每項設定的作用。";
"SETTINGS_START_WITH" = "以下列前綴開頭的設定";
Expand Down

0 comments on commit a671db1

Please sign in to comment.