Skip to content

Commit

Permalink
Merge pull request #19121 from /issues/23931
Browse files Browse the repository at this point in the history
Fix Brave Ads notification for Android
  • Loading branch information
aseren committed Jul 5, 2023
2 parents a10c760 + 2856190 commit c89477c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
android:id="@+id/body_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:layout_marginTop="-2dp"
android:layout_marginBottom="5dp">

<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:layout_below="@id/title"
android:layout_toEndOf="@id/icon_frame"
android:layout_marginBottom="-4dp"
android:layout_marginTop="-4dp">
android:layout_marginTop="-2dp">

<TextView
android:id="@+id/body"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ public class BraveNotificationBuilder extends StandardNotificationBuilder {
private static final int MAX_SCALABLE_PADDING_DP = 3;

/**
* The notification body height in compact view mode for Android S.
* The notification body height in dp for compact view mode for Android 12 and higher.
*/
private static final int COMPACT_BODY_CONTAINER_HEIGHT_S = 40;
private static final float COMPACT_BODY_CONTAINER_HEIGHT_DP = 40f;

/**
* The notification title margin top in dp for compact view mode for Android 12 and higher.
*/
private static final float COMPACT_TITLE_MARGIN_TOP_DP = -4f;

private static Bitmap sBraveIcon;

Expand Down Expand Up @@ -124,8 +129,10 @@ public NotificationWrapper build(NotificationMetadata metadata) {
// - the dimensions become less than before.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
compactView.setViewPadding(R.id.title, 0, 0, 0, 0);
compactView.setViewPadding(R.id.body_container, 0, 0, 0, 0);
compactView.setViewLayoutHeight(R.id.body_container, COMPACT_BODY_CONTAINER_HEIGHT_S,
compactView.setViewLayoutMargin(R.id.title, RemoteViews.MARGIN_TOP,
COMPACT_TITLE_MARGIN_TOP_DP, TypedValue.COMPLEX_UNIT_DIP);
compactView.setViewPadding(R.id.body_container, 0, scaledPadding, 0, 0);
compactView.setViewLayoutHeight(R.id.body_container, COMPACT_BODY_CONTAINER_HEIGHT_DP,
TypedValue.COMPLEX_UNIT_DIP);
compactView.setViewVisibility(R.id.icon_frame, View.GONE);
bigView.setViewVisibility(R.id.icon_frame, View.GONE);
Expand Down

0 comments on commit c89477c

Please sign in to comment.