Skip to content

Commit

Permalink
feat: disable notification bubble
Browse files Browse the repository at this point in the history
Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
  • Loading branch information
NextAlone committed Feb 20, 2023
1 parent 9e69c91 commit f3333ce
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3034,14 +3034,16 @@ private String createNotificationShortcut(NotificationCompat.Builder builder, lo
} else {
icon = IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.book_group);
}
NotificationCompat.BubbleMetadata.Builder bubbleBuilder =
new NotificationCompat.BubbleMetadata.Builder(
PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT),
icon);
bubbleBuilder.setSuppressNotification(openedDialogId == did);
bubbleBuilder.setAutoExpandBubble(false);
bubbleBuilder.setDesiredHeight(AndroidUtilities.dp(640));
builder.setBubbleMetadata(bubbleBuilder.build());
if (!ConfigManager.getBooleanOrFalse(Defines.disableNotificationBubble)) {
NotificationCompat.BubbleMetadata.Builder bubbleBuilder =
new NotificationCompat.BubbleMetadata.Builder(
PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT),
icon);
bubbleBuilder.setSuppressNotification(openedDialogId == did);
bubbleBuilder.setAutoExpandBubble(false);
bubbleBuilder.setDesiredHeight(AndroidUtilities.dp(640));
builder.setBubbleMetadata(bubbleBuilder.build());
}
return id;
} catch (Exception e) {
FileLog.e(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class ChatSettingActivity extends BaseActivity {
private int doNotUnarchiveBySwipeRow;
private int hideInputFieldBotButtonRow;
private int hideMessageSeenTooltipRow;
private int disableNotificationBubbleRow;
private int chat2Row;


Expand Down Expand Up @@ -316,6 +317,11 @@ protected void onItemClick(View view, int position, float x, float y) {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(ConfigManager.getBooleanOrFalse(Defines.hideMessageSeenTooltip));
}
} else if (position == disableNotificationBubbleRow) {
ConfigManager.toggleBoolean(Defines.disableNotificationBubble);
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(ConfigManager.getBooleanOrFalse(Defines.disableNotificationBubble));
}
}
}

Expand Down Expand Up @@ -369,6 +375,7 @@ protected void updateRows() {
doNotUnarchiveBySwipeRow = rowCount++;
hideInputFieldBotButtonRow = rowCount++;
hideMessageSeenTooltipRow = rowCount++;
disableNotificationBubbleRow = rowCount++;
chat2Row = rowCount++;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
Expand Down Expand Up @@ -494,6 +501,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, boole
} else if (position == hideMessageSeenTooltipRow) {
textCell.setTextAndCheck(LocaleController.getString("hideMessageSeenTooltip", R.string.hideMessageSeenTooltip),
ConfigManager.getBooleanOrFalse(Defines.hideMessageSeenTooltip), true);
} else if (position == disableNotificationBubbleRow) {
textCell.setTextAndCheck(LocaleController.getString("disableNotificationBubble", R.string.disableNotificationBubble),
ConfigManager.getBooleanOrFalse(Defines.disableNotificationBubble), false);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class Defines {
public static final String doNotUnarchiveBySwipe = "doNotUnarchiveBySwipe";
public static final String hideInputFieldBotButton = "hideInputFieldBotButton";
public static final String hideMessageSeenTooltip = "hideMessageSeenTooltip";
public static final String disableNotificationBubble = "disableNotificationBubble";

// Custom API
public static final String customAPI = "customAPI";
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values-zh/strings_nnngram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,5 @@
<string name="hideInputFieldBotButton">隐藏输入框机器人按钮</string>
<string name="hideMessageSeenTooltip">隐藏消息已读提示</string>
<string name="ToTheBeginning">回到顶部</string>
<string name="disableNotificationBubble">禁用通知气泡</string>
</resources>
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values/strings_nnngram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,5 @@
<string name="hideInputFieldBotButton">Hide input field bot button</string>
<string name="hideMessageSeenTooltip">Hide message seen tooltip</string>
<string name="ToTheBeginning">To the beginning</string>
<string name="disableNotificationBubble">Disable notification bubble</string>
</resources>

0 comments on commit f3333ce

Please sign in to comment.