Skip to content

Commit

Permalink
feat: Disable Stories
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Aug 13, 2023
1 parent 6e9f272 commit 940b3cd
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18535,6 +18535,7 @@ public StoriesController getStoriesController() {
}

public boolean storiesEnabled() {
if (NaConfig.INSTANCE.getDisableStories().Bool()) return false;
switch (storiesPosting) {
case "premium":
return getUserConfig().isPremium();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8049,7 +8049,7 @@ private void updateFloatingButtonOffset() {
}
}

public boolean storiesEnabled = true;
public boolean storiesEnabled = !NaConfig.INSTANCE.getDisableStories().Bool();
private void updateStoriesPosting() {
final boolean storiesEnabled = getMessagesController().storiesEnabled();
if (this.storiesEnabled != storiesEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
import java.util.SortedSet;
import java.util.TreeSet;

import xyz.nextalone.nagram.NaConfig;

public class StoriesController {

public final static int STATE_READ = 0;
Expand Down Expand Up @@ -187,11 +189,13 @@ public DraftsController getDraftsController() {
}

public boolean hasStories(long dialogId) {
if (NaConfig.INSTANCE.getDisableStories().Bool()) return false;
TLRPC.TL_userStories stories = allStoriesMap.get(dialogId);
return stories != null && !stories.stories.isEmpty();
}

public boolean hasStories() {
if (NaConfig.INSTANCE.getDisableStories().Bool()) return false;
return (dialogListStories != null && dialogListStories.size() > 0) || hasSelfStories();
}

Expand Down Expand Up @@ -892,6 +896,7 @@ public boolean markStoryAsRead(TLRPC.TL_userStories userStories, TLRPC.StoryItem
TLRPC.TL_stories_readStories req = new TLRPC.TL_stories_readStories();
req.user_id = MessagesController.getInstance(currentAccount).getInputUser(dialogId);
req.max_id = storyItem.id;
if (NaConfig.INSTANCE.getDisableSendReadStories().Bool()) return true;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {});
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

import java.util.Collections;

import xyz.nextalone.nagram.NaConfig;

public class StoriesUtilities {

private final static int ANIMATION_SEGMENT_COUNT = 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen
private final AbstractConfigCell repeatConfirmRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.repeatConfirm));
private final AbstractConfigCell dividerConfirms = cellGroup.appendCell(new ConfigCellDivider());

// Story
private final AbstractConfigCell headerStory = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Story")));
private final AbstractConfigCell disableStoriesRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableStories()));
private final AbstractConfigCell disableSendReadStoriesRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableSendReadStories()));
private final AbstractConfigCell dividerStory = cellGroup.appendCell(new ConfigCellDivider());

private final AbstractConfigCell ignoreBlockedRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout")));
private final AbstractConfigCell disableChatActionRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChatAction));
private final AbstractConfigCell disableChoosingStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChoosingSticker));
Expand Down
12 changes: 12 additions & 0 deletions TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,18 @@ object NaConfig {
ConfigItem.configTypeBool,
false
)
val disableStories =
addConfig(
"DisableStories",
ConfigItem.configTypeBool,
false
)
val disableSendReadStories =
addConfig(
"DisableSendReadStories",
ConfigItem.configTypeBool,
false
)

private fun addConfig(
k: String,
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@
<string name="DoNotShareMyPhoneNumber">禁用分享我的手机号码</string>
<string name="DefaultDeleteMenu">默认删除菜单</string>
<string name="DisableSuggestionView">禁用修改手机号码的建议</string>
<string name="DisableStories">禁用动态功能</string>
<string name="DisableSendReadStories">偷偷看动态</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@
<string name="DoNotShareMyPhoneNumber">Do not share my phone number</string>
<string name="DefaultDeleteMenu">Default Delete Menu</string>
<string name="DisableSuggestionView">Disable Profile Settings Suggestion</string>
<string name="DisableStories">Disable Stories</string>
<string name="DisableSendReadStories">Disable Send Read Stories</string>
</resources>

0 comments on commit 940b3cd

Please sign in to comment.