Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ public boolean onLongClick (View v) {
context.currentTdlib().ui().addAccount(context, true, true);
}
});
} else if (itemId == R.id.btn_calls) {
context.currentTdlib().ui().showClearCallHistoryOptions(this);
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11110,6 +11110,10 @@ public boolean canEditSlowMode (long chatId) {
return false;
}

public void clearCallsHistory (boolean revoke, @Nullable Runnable after) {
send(new TdApi.DeleteAllCallMessages(revoke), okHandler(after));
}

public boolean isBroadcastGroup (long chatId) {
TdApi.Supergroup supergroup = chatToSupergroup(chatId);
return supergroup != null && supergroup.isBroadcastGroup;
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/org/thunderdog/challegram/telegram/TdlibUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,31 @@ public void showDeleteOptions (ViewController<?> context, MessageWithProperties
showDeleteOptions(context, new MessageWithProperties[] {message}, null);
}

public void showClearCallHistoryOptions (ViewController<?> context) {
tdlib.send(new TdApi.SearchCallMessages("", 1, false), (result, error) -> {
if (error != null || result.messages.length == 0) {
return;
}
context.runOnUiThreadOptional(() ->
context.showSettings(new SettingsWrapBuilder(R.id.btn_delete)
.addHeaderItem(Lang.getString(R.string.AreYouSureClearCalls))
.setRawItems(new ListItem[] {
new ListItem(ListItem.TYPE_CHECKBOX_OPTION, R.id.btn_deleteAll, 0, R.string.DeleteCallsForEveryone, false)
})
.setIntDelegate((id, result2) -> {
if (id == R.id.btn_delete) {
boolean revoke = result2.get(R.id.btn_deleteAll) != 0;
tdlib.clearCallsHistory(revoke, () ->
UI.showToast(R.string.Done, Toast.LENGTH_SHORT)
);
}
})
.setSaveStr(R.string.Delete)
.setSaveColorId(ColorId.textNegative))
);
});
}

public void showDeleteOptions (final ViewController<?> context, final MessageWithProperties[] messages, final @Nullable Runnable after) {
if (context != null && messages != null && messages.length > 0) {
if (deleteSuperGroupMessages(context, messages, after)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand All @@ -33,6 +34,8 @@
import org.thunderdog.challegram.data.CallItem;
import org.thunderdog.challegram.data.CallSection;
import org.thunderdog.challegram.data.TGFoundChat;
import org.thunderdog.challegram.navigation.HeaderView;
import org.thunderdog.challegram.navigation.MoreDelegate;
import org.thunderdog.challegram.navigation.SettingsWrapBuilder;
import org.thunderdog.challegram.navigation.ViewController;
import org.thunderdog.challegram.telegram.DateChangeListener;
Expand Down Expand Up @@ -66,6 +69,7 @@ public class CallListController extends RecyclerViewController<Void> implements
View.OnClickListener,
Client.ResultHandler,
MessageListener,
MoreDelegate,
DateChangeListener,
View.OnLongClickListener,
BaseView.ActionListProvider, TdlibOptionListener {
Expand All @@ -83,6 +87,36 @@ public CharSequence getName () {
return Lang.getString(R.string.Calls);
}

@Override
protected int getMenuId () {
return messages != null && !messages.isEmpty() ? R.id.menu_btn_more : 0;
}

@Override
public void fillMenuItems (int id, HeaderView header, LinearLayout menu) {
if (id == R.id.menu_btn_more) {
header.addMoreButton(menu, this);
}
}

@Override
public void onMenuItemPressed (int id, View view) {
if (id == R.id.menu_btn_more) {
showMore(new int[] {R.id.btn_clear_recent_calls}, new String[] {Lang.getString(R.string.ClearRecentCalls)});
}
}

@Override
public void onMoreItemPressed (int id) {
if (id == R.id.btn_clear_recent_calls) {
tdlib.ui().showClearCallHistoryOptions(this);
}
}

public boolean hasRecentCalls () {
return messages != null && !messages.isEmpty();
}

private SettingsAdapter adapter;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,12 @@ public boolean onPagerItemLongClick (int index) {
TdApi.ChatList chatList = pagerChatLists.get(index);
showChatListOptions(chatList);
return true;
} else if (index == POSITION_CALLS) {
ViewController<?> controller = getCachedControllerForPosition(index);
if (controller instanceof CallListController && ((CallListController) controller).hasRecentCalls()) {
tdlib.ui().showClearCallHistoryOptions(this);
return true;
}
}
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1428,4 +1428,7 @@
<item type="id" name="btn_playback_speed_1_2" />
<item type="id" name="btn_playback_speed_1_5" />
<item type="id" name="btn_playback_speed_2_0" />
</resources>

<item type="id" name="btn_clear_recent_calls" />

</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5722,6 +5722,9 @@
<string name="xBotUsers_one">%1$s monthly user</string>
<string name="xBotUsers_other">%1$s monthly users</string>

<string name="AreYouSureClearCalls">Do you want to delete all recent calls?</string>
<string name="ClearRecentCalls">Clear recent calls</string>
<string name="DeleteCallsForEveryone">Delete for everyone</string>
<string name="RestrictedContent">Restricted Content</string>
<string name="SensitiveContent">Sensitive Content</string>

Expand Down