Skip to content

Commit

Permalink
feat: shortcut to clear cache for current chat
Browse files Browse the repository at this point in the history
Co-authored-by: dic1911 <[email protected]>
  • Loading branch information
omg-xtao and dic1911 committed Sep 11, 2024
1 parent 0471cb8 commit 748359c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
private boolean loadingDialogs;
private NestedSizeNotifierLayout nestedSizeNotifierLayout;

private long targetDialogId = -1L;

public CacheControlActivity() {}

public CacheControlActivity(Bundle args) {
targetDialogId = args.getLong("dialog_id", -1L);
}

private ActionBarMenuSubItem clearDatabaseItem;
private ActionBarMenuSubItem resetDatabaseItem;
private void updateDatabaseItemSize() {
Expand Down Expand Up @@ -533,6 +541,14 @@ private void loadDialogEntities() {
fillDialogsEntitiesRecursive(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT), TYPE_DOCUMENTS, dilogsFilesEntities, cacheModel);
fillDialogsEntitiesRecursive(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_FILES), TYPE_DOCUMENTS, dilogsFilesEntities, cacheModel);

// ----- Nagram Hook start -----
if (targetDialogId != -1) {
DialogFileEntities entities = dilogsFilesEntities.get(targetDialogId, null);
if (entities != null) AndroidUtilities.runOnUIThread(() -> showClearCacheDialog(entities), 100);
targetDialogId = -1;
}
// ----- Nagram Hook end -----

ArrayList<DialogFileEntities> entities = new ArrayList<>();
ArrayList<Long> unknownUsers = new ArrayList<>();
ArrayList<Long> unknownChats = new ArrayList<>();
Expand Down
15 changes: 12 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,10 @@ public void setAlpha(int a) {
private final static int statistics = 19;
private final static int start_secret_chat = 20;
private final static int gallery_menu_save = 21;
private final static int event_log = 102;
private final static int message_filter = 103;
private final static int view_discussion = 22;
private final static int delete_topic = 23;
private final static int report = 24;

private final static int aliasChannelName = 100;
private final static int edit_name = 101;
private final static int edit_info = 30;
private final static int logout = 31;
Expand All @@ -579,6 +576,11 @@ public void setAlpha(int a) {
private final static int set_username = 43;
private final static int bot_privacy = 44;

private final static int aliasChannelName = 100;
private final static int event_log = 102;
private final static int message_filter = 103;
private final static int clear_cache = 104;

private Rect rect = new Rect();

private TextCell setAvatarCell;
Expand Down Expand Up @@ -2791,6 +2793,11 @@ public void didChangeOwner(TLRPC.User user) {
// args.putLong("user_id", userId);
// presentFragment(new QrActivity(args));
// }
} else if (id == clear_cache) {
Bundle args = new Bundle();
args.putLong("dialog_id", userId != 0 ? dialogId : -chatId);
CacheControlActivity fragment = new CacheControlActivity(args);
presentFragment(fragment);
}
}
});
Expand Down Expand Up @@ -10618,6 +10625,8 @@ private void createActionBarMenu(boolean animated) {

if (selfUser && !myProfile) {
otherItem.addSubItem(logout, R.drawable.msg_leave, LocaleController.getString(R.string.LogOut));
} else {
otherItem.addSubItem(clear_cache, R.drawable.msg_delete, LocaleController.getString(R.string.ClearCache));
}
if (!isPulledDown) {
otherItem.hideSubItem(gallery_menu_save);
Expand Down

0 comments on commit 748359c

Please sign in to comment.