4040import android .graphics .Shader ;
4141import android .graphics .drawable .ColorDrawable ;
4242import android .graphics .drawable .Drawable ;
43- import android .graphics .drawable .GradientDrawable ;
4443import android .media .MediaMetadataRetriever ;
4544import android .os .Build ;
4645import android .os .Bundle ;
109108import org .telegram .messenger .UserObject ;
110109import org .telegram .messenger .Utilities ;
111110import org .telegram .messenger .VideoEditedInfo ;
111+ import org .telegram .messenger .utils .RectFMergeBounding ;
112112import org .telegram .messenger .utils .ViewOutlineProviderImpl ;
113113import org .telegram .tgnet .ConnectionsManager ;
114114import org .telegram .tgnet .TLObject ;
128128import org .telegram .ui .Business .QuickRepliesController ;
129129import org .telegram .ui .ChatActivity ;
130130import org .telegram .ui .Components .Premium .PremiumFeatureBottomSheet ;
131+ import org .telegram .ui .Components .blur3 .Blur3HashImpl ;
131132import org .telegram .ui .Components .blur3 .BlurredBackgroundDrawableViewFactory ;
132133import org .telegram .ui .Components .blur3 .BlurredBackgroundWithFadeDrawable ;
133134import org .telegram .ui .Components .blur3 .DownscaleScrollableNoiseSuppressor ;
134135import org .telegram .ui .Components .blur3 .RenderNodeWithHash ;
135136import org .telegram .ui .Components .blur3 .capture .IBlur3Capture ;
137+ import org .telegram .ui .Components .blur3 .capture .IBlur3Hash ;
136138import org .telegram .ui .Components .blur3 .drawable .BlurredBackgroundDrawable ;
137139import org .telegram .ui .Components .blur3 .drawable .color .impl .BlurredBackgroundProviderImpl ;
138140import org .telegram .ui .Components .blur3 .source .BlurredBackgroundSourceColor ;
@@ -1173,7 +1175,7 @@ public ChatAttachAlert(Context context, final @Nullable BaseFragment parentFragm
11731175 iBlur3SourceGlass = new BlurredBackgroundSourceRenderNode (null );
11741176 iBlur3SourceGlass .setupRenderer (new RenderNodeWithHash .Renderer () {
11751177 @ Override
1176- public void renderNodeCalculateHash (RenderNodeWithHash . HashBuilder hash ) {
1178+ public void renderNodeCalculateHash (IBlur3Hash hash ) {
11771179 hash .add (getThemedColor (Theme .key_windowBackgroundWhite ));
11781180 hash .add (SharedConfig .chatBlurEnabled ());
11791181 }
@@ -1190,7 +1192,7 @@ public void renderNodeUpdateDisplayList(Canvas canvas) {
11901192 iBlur3SourceGlassFrosted = new BlurredBackgroundSourceRenderNode (null );
11911193 iBlur3SourceGlassFrosted .setupRenderer (new RenderNodeWithHash .Renderer () {
11921194 @ Override
1193- public void renderNodeCalculateHash (RenderNodeWithHash . HashBuilder hash ) {
1195+ public void renderNodeCalculateHash (IBlur3Hash hash ) {
11941196 hash .add (getThemedColor (Theme .key_windowBackgroundWhite ));
11951197 hash .add (SharedConfig .chatBlurEnabled ());
11961198 }
@@ -1219,18 +1221,14 @@ public void renderNodeUpdateDisplayList(Canvas canvas) {
12191221
12201222 iBlur3Capture = new IBlur3Capture () {
12211223 @ Override
1222- public long captureCalculateHash (RectF position ) {
1223- long hash = 0 ;
1224+ public void captureCalculateHash (IBlur3Hash builder , RectF position ) {
12241225 for (int a = 0 ; a < 2 ; a ++) {
12251226 AttachAlertLayout layout = a == 0 ? currentAttachLayout : nextAttachLayout ;
12261227 if (layout != null && layout .iBlur3Capture != null && layout .getVisibility () == View .VISIBLE && layout .getAlpha () > 0.9f ) {
1227- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
1228- hash = MediaDataController .calcHash (hash , layout .getUniqueDrawingId ());
1229- }
1230- hash = MediaDataController .calcHash (hash , layout .iBlur3Capture .captureCalculateHash (position ));
1228+ builder .add (layout );
1229+ layout .iBlur3Capture .captureCalculateHash (builder , position );
12311230 }
12321231 }
1233- return hash ;
12341232 }
12351233
12361234 @ Override
@@ -1641,6 +1639,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
16411639 if (captionAbove ) {
16421640 updateCommentTextViewPosition ();
16431641 }
1642+ if (photoLayout != null && photoLayout .gridView != null && photoLayout .gridView .getFastScroll () != null ) {
1643+ photoLayout .gridView .getFastScroll ().topOffset = ActionBar .getCurrentActionBarHeight () + photoLayout .listAdditionalH
1644+ + (captionAbove ? (int ) (topCommentContainer .getMeasuredHeight () * topCommentContainer .getAlpha ()) : 0 );
1645+ photoLayout .gridView .getFastScroll ().invalidate ();
1646+ }
16441647 }
16451648
16461649 @ Override
@@ -1975,18 +1978,20 @@ protected void dispatchDraw(Canvas canvas) {
19751978
19761979 @ Override
19771980 public void drawBlurRect (Canvas canvas , float y , Rect rectTmp , Paint blurScrimPaint , boolean top ) {
1978- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .Q || !SharedConfig .chatBlurEnabled () || iBlur3SourceGlassFrosted == null ) {
1981+ if (currentAttachLayout != photoLayout || Build .VERSION .SDK_INT < Build .VERSION_CODES .Q || !SharedConfig .chatBlurEnabled () || iBlur3SourceGlassFrosted == null || ! BlurredBackgroundProviderImpl . checkBlurEnabled ( currentAccount , resourcesProvider ) ) {
19791982 canvas .drawRect (rectTmp , blurScrimPaint );
19801983 return ;
19811984 }
19821985
1986+ final boolean isThemeLight = resourcesProvider != null ? !resourcesProvider .isDark () : !Theme .isCurrentThemeDark ();
1987+ int blurAlpha = isThemeLight ? 216 : ChatActivity .ACTION_BAR_BLUR_ALPHA ;
19831988 canvas .save ();
19841989 canvas .translate (0 , -y );
19851990 iBlur3SourceGlassFrosted .draw (canvas , rectTmp .left , rectTmp .top + y , rectTmp .right , rectTmp .bottom + y );
19861991 canvas .restore ();
19871992
19881993 final int oldScrimAlpha = blurScrimPaint .getAlpha ();
1989- blurScrimPaint .setAlpha (ChatActivity . ACTION_BAR_BLUR_ALPHA );
1994+ blurScrimPaint .setAlpha (blurAlpha );
19901995 canvas .drawRect (rectTmp , blurScrimPaint );
19911996 blurScrimPaint .setAlpha (oldScrimAlpha );
19921997 }
@@ -2098,7 +2103,7 @@ public void setAlpha(float alpha) {
20982103 actionBar .setTitleColor (getThemedColor (Theme .key_dialogTextBlack ));
20992104 actionBar .setOccupyStatusBar (true );
21002105 actionBar .setAlpha (0.0f );
2101- // actionBar.setDrawBlurBackground(sizeNotifierFrameLayout);
2106+ actionBar .setDrawBlurBackground (sizeNotifierFrameLayout );
21022107 actionBar .setActionBarMenuOnItemClick (new ActionBar .ActionBarMenuOnItemClick () {
21032108 @ Override
21042109 public void onItemClick (int id ) {
@@ -3816,6 +3821,10 @@ protected void onDraw(Canvas canvas) {
38163821 navBarColorKey = -1 ;
38173822 }
38183823
3824+ if (photoLayout != null ) {
3825+ photoLayout .gridView .getFastScroll ().applyBlurDrawables (iBlur3FactoryLiquidGlass , BlurredBackgroundProviderImpl .topPanel (resourcesProvider ));
3826+ }
3827+
38193828 passcodeView = new PasscodeView (context );
38203829 containerView .addView (passcodeView , LayoutHelper .createFrame (LayoutHelper .MATCH_PARENT , LayoutHelper .MATCH_PARENT ));
38213830 }
@@ -6297,8 +6306,8 @@ private void updatedTopCaptionHeight() {
62976306 if (photoLayout != null ) {
62986307 photoLayout .checkCameraViewPosition ();
62996308 if (photoLayout .gridView != null && photoLayout .gridView .getFastScroll () != null ) {
6300- photoLayout .gridView .getFastScroll ().topOffset = ( captionAbove ? ( int ) ( topCommentContainer . getMeasuredHeight () * topCommentContainer . getAlpha ()) : 0 )
6301- + ActionBar . getCurrentActionBarHeight () + AndroidUtilities . statusBarHeight ;
6309+ photoLayout .gridView .getFastScroll ().topOffset = ActionBar . getCurrentActionBarHeight () + photoLayout . listAdditionalH
6310+ + ( captionAbove ? ( int ) ( topCommentContainer . getMeasuredHeight () * topCommentContainer . getAlpha ()) : 0 ) ;
63026311 photoLayout .gridView .getFastScroll ().invalidate ();
63036312 }
63046313 }
@@ -6328,26 +6337,45 @@ private void toggleCaptionAbove() {
63286337
63296338 private final ArrayList <RectF > iBlur3Positions = new ArrayList <>();
63306339 private final RectF iBlur3PositionActionBar = new RectF ();
6331- private final RectF iBlur3PositionMainTabs = new RectF (); {
6332- // iBlur3Positions.add(iBlur3PositionActionBar);
6340+ private final RectF iBlur3PositionMainTabs = new RectF ();
6341+ private final RectF iBlur3PositionFastScroll = new RectF ();
6342+ {
6343+ iBlur3Positions .add (iBlur3PositionActionBar );
63336344 iBlur3Positions .add (iBlur3PositionMainTabs );
6345+ iBlur3Positions .add (iBlur3PositionFastScroll );
63346346 }
63356347
6348+ private final ArrayList <RectF > iBlur3PositionsMerged = new ArrayList <>();
6349+
63366350 private void blur3_InvalidateBlur () {
63376351 if (Build .VERSION .SDK_INT < Build .VERSION_CODES .S || scrollableViewNoiseSuppressor == null ) {
63386352 return ;
63396353 }
63406354
63416355 ViewPositionWatcher .computeRectInParent (buttonsRecyclerViewWrapper , containerView , iBlur3PositionMainTabs );
63426356
6343-
6344- // iBlur3PositionActionBar.set (0, 0, getMeasuredWidth(), getMeasuredHeight( ));
6357+ iBlur3PositionActionBar . set ( 0 , 0 , containerView . getMeasuredWidth (), actionBar . getMeasuredHeight ());
6358+ iBlur3PositionActionBar .inset (0 , - dp ( 48 ));
63456359
63466360 final int bottomBlurHeight = Math .max (AndroidUtilities .navigationBarHeight , getEmojiPadding ()) + dp (180 );
63476361 iBlur3PositionMainTabs .set (0 , containerView .getMeasuredHeight () - bottomBlurHeight , containerView .getMeasuredWidth (), containerView .getMeasuredHeight ());
63486362 iBlur3PositionMainTabs .inset (0 , LiteMode .isEnabled (LiteMode .FLAG_LIQUID_GLASS ) ? 0 : -dp (48 ));
63496363
6350- scrollableViewNoiseSuppressor .setupRenderNodes (iBlur3Positions , 1 );
6364+ boolean hasFastScroll = false ;
6365+ if (currentAttachLayout == photoLayout && photoLayout != null && photoLayout .gridView .getFastScroll () != null ) {
6366+ photoLayout .gridView .getFastScroll ().fillDrawablesRect (iBlur3PositionFastScroll );
6367+
6368+ ViewPositionWatcher .computeRectInParent (photoLayout .gridView .getFastScroll (), containerView , AndroidUtilities .rectTmp );
6369+
6370+ iBlur3PositionFastScroll .offset (AndroidUtilities .rectTmp .left , AndroidUtilities .rectTmp .top );
6371+ iBlur3PositionFastScroll .inset (-dp (48 ), -dp (48 ));
6372+ iBlur3PositionFastScroll .left = Math .max (0 , iBlur3PositionFastScroll .left );
6373+ iBlur3PositionFastScroll .right = Math .min (containerView .getMeasuredWidth (), iBlur3PositionFastScroll .right );
6374+ hasFastScroll = true ;
6375+ }
6376+
6377+ final int mergedPositionsCount = RectFMergeBounding .mergeOverlapping (iBlur3Positions , hasFastScroll ? 3 : 2 , iBlur3PositionsMerged );
6378+ scrollableViewNoiseSuppressor .setupRenderNodes (iBlur3PositionsMerged , mergedPositionsCount );
63516379 scrollableViewNoiseSuppressor .invalidateResultRenderNodes (iBlur3Capture , containerView .getMeasuredWidth (), containerView .getMeasuredHeight ());
63526380 }
63536381}
0 commit comments