Skip to content

Commit 882e505

Browse files
committed
Simplified ForkSettingsActivity with declarative settings structure.
1 parent 8963d38 commit 882e505

2 files changed

Lines changed: 203 additions & 601 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.telegram.ui;
2+
3+
import android.content.SharedPreferences;
4+
import org.telegram.messenger.MessagesController;
5+
import org.telegram.messenger.SharedConfig;
6+
7+
public enum ForkSetting {
8+
HIDE_SENSITIVE_DATA("hideSensitiveData", false),
9+
SQUARE_AVATARS("squareAvatars", false),
10+
PHOTO_HAS_STICKER("photoHasSticker", true),
11+
SHOW_NOTIFICATION_CONTENT("showNotificationContent", true),
12+
UNMUTED_ON_TOP("unmutedOnTop", false),
13+
REAR_VIDEO_MESSAGES("rearVideoMessages", false),
14+
REPLACE_FORWARD("replaceForward", false),
15+
MENTION_BY_NAME("mentionByName", false),
16+
OPEN_ARCHIVE_ON_PULL("openArchiveOnPull", false),
17+
HIDE_BOTTOM_BUTTON("hideBottomButton", false),
18+
DISABLE_FLIP_PHOTOS("disableFlipPhotos", false),
19+
FORMAT_WITH_SECONDS("formatWithSeconds", false),
20+
DISABLE_THUMBS_IN_DIALOG_LIST("disableThumbsInDialogList", false),
21+
DISABLE_GLOBAL_SEARCH("disableGlobalSearch", false),
22+
CUSTOM_TITLE("customTitle", false),
23+
FULL_RECENT_STICKERS("fullRecentStickers", false),
24+
HIDE_SEND_AS("hideSendAs", false),
25+
DISABLE_QUICK_REACTION("disableQuickReaction", false),
26+
DISABLE_LOCKED_ANIMATED_EMOJI("disableLockedAnimatedEmoji", false),
27+
DISABLE_PARAMETERS_FROM_BOT_LINKS("disableParametersFromBotLinks", false),
28+
LOCK_PREMIUM("lockPremium", false),
29+
ADD_ITEM_TO_DELETE_ALL_UNPINNED_MESSAGES("addItemToDeleteAllUnpinnedMessages", false),
30+
LARGE_PHOTO("largePhoto", false),
31+
DISABLE_SLIDE_TO_NEXT_CHANNEL("disableSlideToNextChannel", false),
32+
DISABLE_RECENT_FILES_ATTACHMENT("disableRecentFilesAttachment", false),
33+
BOT_SKIP_SHARE("botSkipShare", false),
34+
BOT_SKIP_FULLSCREEN("botSkipFullscreen", false),
35+
DISABLE_DEFAULT_IN_APP_BROWSER("disableDefaultInAppBrowser", false),
36+
SYNC_PINS("syncPins", true),
37+
INAPP_CAMERA("inappCamera", true),
38+
SYSTEM_CAMERA("systemCamera", false);
39+
40+
public final String key;
41+
public final boolean defaultValue;
42+
43+
ForkSetting(String key, boolean defaultValue) {
44+
this.key = key;
45+
this.defaultValue = defaultValue;
46+
}
47+
48+
public boolean get() {
49+
return MessagesController.getGlobalMainSettings().getBoolean(key, defaultValue);
50+
}
51+
52+
public boolean toggle() {
53+
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
54+
boolean newValue = !get();
55+
editor.putBoolean(key, newValue);
56+
editor.apply();
57+
return newValue;
58+
}
59+
60+
public boolean isVisible() {
61+
switch (this) {
62+
case HIDE_SENSITIVE_DATA:
63+
case HIDE_BOTTOM_BUTTON:
64+
return !SharedConfig.isUserOwner();
65+
default:
66+
return true;
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)