Search in sources :

Example 1 with HintView

use of org.telegram.ui.Components.HintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class ThemePreviewActivity method showAnimationHint.

private void showAnimationHint() {
    if (page2 == null || messagesCheckBoxView == null || accent.myMessagesGradientAccentColor2 == 0) {
        return;
    }
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    if (preferences.getBoolean("bganimationhint", false)) {
        return;
    }
    if (animationHint == null) {
        animationHint = new HintView(getParentActivity(), 8);
        animationHint.setShowingDuration(5000);
        animationHint.setAlpha(0);
        animationHint.setVisibility(View.INVISIBLE);
        animationHint.setText(LocaleController.getString("BackgroundAnimateInfo", R.string.BackgroundAnimateInfo));
        animationHint.setExtraTranslationY(AndroidUtilities.dp(6));
        frameLayout.addView(animationHint, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0));
    }
    AndroidUtilities.runOnUIThread(() -> {
        if (colorType != 3) {
            return;
        }
        preferences.edit().putBoolean("bganimationhint", true).commit();
        animationHint.showForView(messagesCheckBoxView[0], true);
    }, 500);
}
Also used : SharedPreferences(android.content.SharedPreferences) HintView(org.telegram.ui.Components.HintView)

Example 2 with HintView

use of org.telegram.ui.Components.HintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class LocationActivity method createView.

@Override
public View createView(Context context) {
    searchWas = false;
    searching = false;
    searchInProgress = false;
    if (adapter != null) {
        adapter.destroy();
    }
    if (searchAdapter != null) {
        searchAdapter.destroy();
    }
    if (chatLocation != null) {
        userLocation = new Location("network");
        userLocation.setLatitude(chatLocation.geo_point.lat);
        userLocation.setLongitude(chatLocation.geo_point._long);
    } else if (messageObject != null) {
        userLocation = new Location("network");
        userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
        userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
    }
    locationDenied = Build.VERSION.SDK_INT >= 23 && getParentActivity() != null && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED;
    actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
    actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
    actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (AndroidUtilities.isTablet()) {
        actionBar.setOccupyStatusBar(false);
    }
    actionBar.setAddToContainer(false);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == open_in) {
                try {
                    double lat = messageObject.messageOwner.media.geo.lat;
                    double lon = messageObject.messageOwner.media.geo._long;
                    getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon)));
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == share_live_location) {
                openShareLiveLocation(0);
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    if (chatLocation != null) {
        actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
    } else if (messageObject != null) {
        if (messageObject.isLiveLocation()) {
            actionBar.setTitle(LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation));
        } else {
            if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) {
                actionBar.setTitle(LocaleController.getString("SharedPlace", R.string.SharedPlace));
            } else {
                actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
            }
            otherItem = menu.addItem(0, R.drawable.ic_ab_other);
            otherItem.addSubItem(open_in, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
            if (!getLocationController().isSharingLocation(dialogId)) {
                otherItem.addSubItem(share_live_location, R.drawable.menu_location, LocaleController.getString("SendLiveLocationMenu", R.string.SendLiveLocationMenu));
            }
            otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
        }
    } else {
        actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
        if (locationType != LOCATION_TYPE_GROUP) {
            overlayView = new MapOverlayView(context);
            searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {

                @Override
                public void onSearchExpand() {
                    searching = true;
                }

                @Override
                public void onSearchCollapse() {
                    searching = false;
                    searchWas = false;
                    searchAdapter.searchDelayed(null, null);
                    updateEmptyView();
                }

                @Override
                public void onTextChanged(EditText editText) {
                    if (searchAdapter == null) {
                        return;
                    }
                    String text = editText.getText().toString();
                    if (text.length() != 0) {
                        searchWas = true;
                        searchItem.setShowSearchProgress(true);
                        if (otherItem != null) {
                            otherItem.setVisibility(View.GONE);
                        }
                        listView.setVisibility(View.GONE);
                        mapViewClip.setVisibility(View.GONE);
                        if (searchListView.getAdapter() != searchAdapter) {
                            searchListView.setAdapter(searchAdapter);
                        }
                        searchListView.setVisibility(View.VISIBLE);
                        searchInProgress = searchAdapter.getItemCount() == 0;
                    } else {
                        if (otherItem != null) {
                            otherItem.setVisibility(View.VISIBLE);
                        }
                        listView.setVisibility(View.VISIBLE);
                        mapViewClip.setVisibility(View.VISIBLE);
                        searchListView.setAdapter(null);
                        searchListView.setVisibility(View.GONE);
                    }
                    updateEmptyView();
                    searchAdapter.searchDelayed(text, userLocation);
                }
            });
            searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
            searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
            EditTextBoldCursor editText = searchItem.getSearchField();
            editText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
            editText.setCursorColor(Theme.getColor(Theme.key_dialogTextBlack));
            editText.setHintTextColor(Theme.getColor(Theme.key_chat_messagePanelHint));
        }
    }
    fragmentView = new FrameLayout(context) {

        private boolean first = true;

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            if (changed) {
                fixLayoutInternal(first);
                first = false;
            } else {
                updateClipView(true);
            }
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == actionBar && parentLayout != null) {
                parentLayout.drawHeaderShadow(canvas, actionBar.getMeasuredHeight());
            }
            return result;
        }
    };
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    fragmentView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY));
    Rect padding = new Rect();
    shadowDrawable.getPadding(padding);
    FrameLayout.LayoutParams layoutParams;
    if (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE) {
        layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(21) + padding.top);
    } else {
        layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(6) + padding.top);
    }
    layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
    mapViewClip = new FrameLayout(context) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (overlayView != null) {
                overlayView.updatePositions();
            }
        }
    };
    mapViewClip.setBackgroundDrawable(new MapPlaceholderDrawable());
    if (messageObject == null && (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE)) {
        searchAreaButton = new SearchButton(context);
        searchAreaButton.setTranslationX(-AndroidUtilities.dp(80));
        Drawable drawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
        if (Build.VERSION.SDK_INT < 21) {
            Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.places_btn).mutate();
            shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
            CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, AndroidUtilities.dp(2), AndroidUtilities.dp(2));
            combinedDrawable.setFullsize(true);
            drawable = combinedDrawable;
        } else {
            StateListAnimator animator = new StateListAnimator();
            animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(searchAreaButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
            animator.addState(new int[] {}, ObjectAnimator.ofFloat(searchAreaButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
            searchAreaButton.setStateListAnimator(animator);
            searchAreaButton.setOutlineProvider(new ViewOutlineProvider() {

                @SuppressLint("NewApi")
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight(), view.getMeasuredHeight() / 2);
                }
            });
        }
        searchAreaButton.setBackgroundDrawable(drawable);
        searchAreaButton.setTextColor(Theme.getColor(Theme.key_location_actionActiveIcon));
        searchAreaButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        searchAreaButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        searchAreaButton.setText(LocaleController.getString("PlacesInThisArea", R.string.PlacesInThisArea));
        searchAreaButton.setGravity(Gravity.CENTER);
        searchAreaButton.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
        mapViewClip.addView(searchAreaButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 80, 12, 80, 0));
        searchAreaButton.setOnClickListener(v -> {
            showSearchPlacesButton(false);
            adapter.searchPlacesWithQuery(null, userLocation, true, true);
            searchedForCustomLocations = true;
            showResults();
        });
    }
    mapTypeButton = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_location_actionIcon));
    mapTypeButton.setClickable(true);
    mapTypeButton.setSubMenuOpenSide(2);
    mapTypeButton.setAdditionalXOffset(AndroidUtilities.dp(10));
    mapTypeButton.setAdditionalYOffset(-AndroidUtilities.dp(10));
    mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM");
    mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia");
    mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark");
    mapTypeButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(mapTypeButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(mapTypeButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        mapTypeButton.setStateListAnimator(animator);
        mapTypeButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    mapTypeButton.setBackgroundDrawable(drawable);
    mapTypeButton.setIcon(R.drawable.location_type);
    mapViewClip.addView(mapTypeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.TOP, 0, 12, 12, 0));
    mapTypeButton.setOnClickListener(v -> mapTypeButton.toggleSubMenu());
    mapTypeButton.setDelegate(id -> {
        if (mapView == null) {
            return;
        }
        if (id == map_list_menu_osm) {
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
            mapView.setTileSource(TileSourceFactory.MAPNIK);
        } else if (id == map_list_menu_wiki) {
            // Create a custom tile source
            ITileSource tileSource = new XYTileSource("Wikimedia", 0, 19, 256, ".png", new String[] { "https://maps.wikimedia.org/osm-intl/" }, "© OpenStreetMap contributors");
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
            mapView.setTileSource(tileSource);
        } else if (id == map_list_menu_cartodark) {
            // Create a custom tile source
            ITileSource tileSource = new XYTileSource("Carto Dark", 0, 20, 256, ".png", new String[] { "https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-b.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-d.global.ssl.fastly.net/dark_all/" }, "© OpenStreetMap contributors, © CARTO");
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors, © <a href=\"https://carto.com/attributions\">CARTO</a>"));
            mapView.setTileSource(tileSource);
        }
    });
    mapViewClip.addView(getAttributionOverlay(context), LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 0 : 4, 0, LocaleController.isRTL ? 4 : 0, 20));
    locationButton = new ImageView(context);
    drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(locationButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(locationButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        locationButton.setStateListAnimator(animator);
        locationButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    locationButton.setBackgroundDrawable(drawable);
    locationButton.setImageResource(R.drawable.location_current);
    locationButton.setScaleType(ImageView.ScaleType.CENTER);
    locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionActiveIcon), PorterDuff.Mode.MULTIPLY));
    locationButton.setTag(Theme.key_location_actionActiveIcon);
    locationButton.setContentDescription(LocaleController.getString("AccDescrMyLocation", R.string.AccDescrMyLocation));
    FrameLayout.LayoutParams layoutParams1 = LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 12, 12);
    layoutParams1.bottomMargin += layoutParams.height - padding.top;
    mapViewClip.addView(locationButton, layoutParams1);
    locationButton.setOnClickListener(v -> {
        if (Build.VERSION.SDK_INT >= 23) {
            Activity activity = getParentActivity();
            if (activity != null) {
                if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    showPermissionAlert(false);
                    return;
                }
            }
        }
        if (!checkGpsEnabled()) {
            return;
        }
        if (messageObject != null || chatLocation != null) {
            if (myLocation != null && mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(myLocation.getLatitude(), myLocation.getLongitude()), mapView.getMaxZoomLevel() - 2, null);
            }
        } else {
            if (myLocation != null && mapView != null) {
                locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionActiveIcon), PorterDuff.Mode.MULTIPLY));
                locationButton.setTag(Theme.key_location_actionActiveIcon);
                adapter.setCustomLocation(null);
                userLocationMoved = false;
                showSearchPlacesButton(false);
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(myLocation.getLatitude(), myLocation.getLongitude()));
                if (searchedForCustomLocations) {
                    if (myLocation != null) {
                        adapter.searchPlacesWithQuery(null, myLocation, true, true);
                    }
                    searchedForCustomLocations = false;
                    showResults();
                }
            }
        }
        removeInfoView();
    });
    proximityButton = new ImageView(context);
    drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(proximityButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(proximityButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        proximityButton.setStateListAnimator(animator);
        proximityButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    proximityButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
    proximityButton.setBackgroundDrawable(drawable);
    proximityButton.setScaleType(ImageView.ScaleType.CENTER);
    proximityButton.setContentDescription(LocaleController.getString("AccDescrLocationNotify", R.string.AccDescrLocationNotify));
    mapViewClip.addView(proximityButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.TOP, 0, 12 + 50, 12, 0));
    proximityButton.setOnClickListener(v -> {
        if (getParentActivity() == null || myLocation == null || !checkGpsEnabled() || mapView == null) {
            return;
        }
        if (hintView != null) {
            hintView.hide();
        }
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        preferences.edit().putInt("proximityhint", 3).commit();
        LocationController.SharingLocationInfo info = getLocationController().getSharingLocationInfo(dialogId);
        if (canUndo) {
            undoView[0].hide(true, 1);
        }
        if (info != null && info.proximityMeters > 0) {
            proximityButton.setImageResource(R.drawable.msg_location_alert);
            if (proximityCircle != null) {
                mapView.getOverlayManager().remove(proximityCircle);
                proximityCircle = null;
            }
            canUndo = true;
            getUndoView().showWithAction(0, UndoView.ACTION_PROXIMITY_REMOVED, 0, null, () -> {
                getLocationController().setProximityLocation(dialogId, 0, true);
                canUndo = false;
            }, () -> {
                proximityButton.setImageResource(R.drawable.msg_location_alert2);
                createCircle(info.proximityMeters);
                canUndo = false;
            });
            return;
        }
        openProximityAlert();
    });
    TLRPC.Chat chat = null;
    if (DialogObject.isChatDialog(dialogId)) {
        chat = getMessagesController().getChat(-dialogId);
    }
    if (messageObject == null || !messageObject.isLiveLocation() || messageObject.isExpiredLiveLocation(getConnectionsManager().getCurrentTime()) || ChatObject.isChannel(chat) && !chat.megagroup) {
        proximityButton.setVisibility(View.GONE);
        proximityButton.setImageResource(R.drawable.msg_location_alert);
    } else {
        LocationController.SharingLocationInfo myInfo = getLocationController().getSharingLocationInfo(dialogId);
        if (myInfo != null && myInfo.proximityMeters > 0) {
            proximityButton.setImageResource(R.drawable.msg_location_alert2);
        } else {
            if (DialogObject.isUserDialog(dialogId) && messageObject.getFromChatId() == getUserConfig().getClientUserId()) {
                proximityButton.setVisibility(View.INVISIBLE);
                proximityButton.setAlpha(0.0f);
                proximityButton.setScaleX(0.4f);
                proximityButton.setScaleY(0.4f);
            }
            proximityButton.setImageResource(R.drawable.msg_location_alert);
        }
    }
    hintView = new HintView(context, 6, true);
    hintView.setVisibility(View.INVISIBLE);
    hintView.setShowingDuration(4000);
    mapViewClip.addView(hintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0));
    emptyView = new LinearLayout(context);
    emptyView.setOrientation(LinearLayout.VERTICAL);
    emptyView.setGravity(Gravity.CENTER_HORIZONTAL);
    emptyView.setPadding(0, AndroidUtilities.dp(60 + 100), 0, 0);
    emptyView.setVisibility(View.GONE);
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    emptyView.setOnTouchListener((v, event) -> true);
    emptyImageView = new ImageView(context);
    emptyImageView.setImageResource(R.drawable.location_empty);
    emptyImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogEmptyImage), PorterDuff.Mode.MULTIPLY));
    emptyView.addView(emptyImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
    emptyTitleTextView = new TextView(context);
    emptyTitleTextView.setTextColor(Theme.getColor(Theme.key_dialogEmptyText));
    emptyTitleTextView.setGravity(Gravity.CENTER);
    emptyTitleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    emptyTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    emptyTitleTextView.setText(LocaleController.getString("NoPlacesFound", R.string.NoPlacesFound));
    emptyView.addView(emptyTitleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 11, 0, 0));
    emptySubtitleTextView = new TextView(context);
    emptySubtitleTextView.setTextColor(Theme.getColor(Theme.key_dialogEmptyText));
    emptySubtitleTextView.setGravity(Gravity.CENTER);
    emptySubtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    emptySubtitleTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0);
    emptyView.addView(emptySubtitleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 6, 0, 0));
    listView = new RecyclerListView(context);
    listView.setAdapter(adapter = new LocationActivityAdapter(context, locationType, dialogId, false, null) {

        @Override
        protected void onDirectionClick() {
            if (Build.VERSION.SDK_INT >= 23) {
                Activity activity = getParentActivity();
                if (activity != null) {
                    if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        showPermissionAlert(true);
                        return;
                    }
                }
            }
            if (myLocation != null) {
                try {
                    Intent intent;
                    if (messageObject != null) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long)));
                    } else {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), chatLocation.geo_point.lat, chatLocation.geo_point._long)));
                    }
                    getParentActivity().startActivity(intent);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        }
    });
    adapter.setMyLocationDenied(locationDenied);
    adapter.setUpdateRunnable(() -> updateClipView(false));
    listView.setVerticalScrollBarEnabled(false);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
            if (!scrolling && forceUpdate != null) {
                forceUpdate = null;
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateClipView(false);
            if (forceUpdate != null) {
                yOffset += dy;
            }
        }
    });
    ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
    listView.setOnItemClickListener((view, position) -> {
        if (locationType == LOCATION_TYPE_GROUP) {
            if (position == 1) {
                TLRPC.TL_messageMediaVenue venue = (TLRPC.TL_messageMediaVenue) adapter.getItem(position);
                if (venue == null) {
                    return;
                }
                if (dialogId == 0) {
                    delegate.didSelectLocation(venue, LOCATION_TYPE_GROUP, true, 0);
                    finishFragment();
                } else {
                    final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(getParentActivity(), 3) };
                    TLRPC.TL_channels_editLocation req = new TLRPC.TL_channels_editLocation();
                    req.address = venue.address;
                    req.channel = getMessagesController().getInputChannel(-dialogId);
                    req.geo_point = new TLRPC.TL_inputGeoPoint();
                    req.geo_point.lat = venue.geo.lat;
                    req.geo_point._long = venue.geo._long;
                    int requestId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                        try {
                            progressDialog[0].dismiss();
                        } catch (Throwable ignore) {
                        }
                        progressDialog[0] = null;
                        delegate.didSelectLocation(venue, LOCATION_TYPE_GROUP, true, 0);
                        finishFragment();
                    }));
                    progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
                    showDialog(progressDialog[0]);
                }
            }
        } else if (locationType == LOCATION_TYPE_GROUP_VIEW) {
            if (mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(chatLocation.geo_point.lat, chatLocation.geo_point._long), mapView.getMaxZoomLevel() - 2, null);
            }
        } else if (position == 1 && messageObject != null && (!messageObject.isLiveLocation() || locationType == LOCATION_TYPE_LIVE_VIEW)) {
            if (mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long), mapView.getMaxZoomLevel() - 2, null);
            }
        } else if (position == 1 && locationType != 2) {
            if (delegate != null && userLocation != null) {
                if (lastPressedMarkerView != null) {
                    lastPressedMarkerView.callOnClick();
                } else {
                    TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo();
                    location.geo = new TLRPC.TL_geoPoint();
                    location.geo.lat = AndroidUtilities.fixLocationCoord(userLocation.getLatitude());
                    location.geo._long = AndroidUtilities.fixLocationCoord(userLocation.getLongitude());
                    if (parentFragment != null && parentFragment.isInScheduleMode()) {
                        AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                            delegate.didSelectLocation(location, locationType, notify, scheduleDate);
                            finishFragment();
                        });
                    } else {
                        delegate.didSelectLocation(location, locationType, true, 0);
                        finishFragment();
                    }
                }
            }
        } else if (position == 2 && locationType == 1 || position == 1 && locationType == 2 || position == 3 && locationType == 3) {
            if (getLocationController().isSharingLocation(dialogId)) {
                getLocationController().removeSharingLocation(dialogId);
                finishFragment();
            } else {
                openShareLiveLocation(0);
            }
        } else {
            Object object = adapter.getItem(position);
            if (object instanceof TLRPC.TL_messageMediaVenue) {
                if (parentFragment != null && parentFragment.isInScheduleMode()) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                        delegate.didSelectLocation((TLRPC.TL_messageMediaVenue) object, locationType, notify, scheduleDate);
                        finishFragment();
                    });
                } else {
                    delegate.didSelectLocation((TLRPC.TL_messageMediaVenue) object, locationType, true, 0);
                    finishFragment();
                }
            } else if (object instanceof LiveLocation) {
                LiveLocation liveLocation = (LiveLocation) object;
                final IMapController controller = mapView.getController();
                controller.animateTo(liveLocation.marker.getPosition(), mapView.getMaxZoomLevel() - 2, null);
            }
        }
    });
    adapter.setDelegate(dialogId, this::updatePlacesMarkers);
    adapter.setOverScrollHeight(overScrollHeight);
    frameLayout.addView(mapViewClip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
    mapView = new MapView(context) {

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            MotionEvent eventToRecycle = null;
            if (yOffset != 0) {
                ev = eventToRecycle = MotionEvent.obtain(ev);
                eventToRecycle.offsetLocation(0, -yOffset / 2);
            }
            boolean result = super.dispatchTouchEvent(ev);
            if (eventToRecycle != null) {
                eventToRecycle.recycle();
            }
            return result;
        }

        @Override
        public boolean onTouchEvent(MotionEvent ev) {
            if (messageObject == null && chatLocation == null) {
                if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                    if (animatorSet != null) {
                        animatorSet.cancel();
                    }
                    animatorSet = new AnimatorSet();
                    animatorSet.setDuration(200);
                    animatorSet.playTogether(ObjectAnimator.ofFloat(markerImageView, View.TRANSLATION_Y, markerTop - AndroidUtilities.dp(10)));
                    animatorSet.start();
                } else if (ev.getAction() == MotionEvent.ACTION_UP) {
                    if (animatorSet != null) {
                        animatorSet.cancel();
                    }
                    yOffset = 0;
                    animatorSet = new AnimatorSet();
                    animatorSet.setDuration(200);
                    animatorSet.playTogether(ObjectAnimator.ofFloat(markerImageView, View.TRANSLATION_Y, markerTop));
                    animatorSet.start();
                    adapter.fetchLocationAddress();
                }
                if (ev.getAction() == MotionEvent.ACTION_MOVE) {
                    if (!userLocationMoved) {
                        locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
                        locationButton.setTag(Theme.key_location_actionIcon);
                        userLocationMoved = true;
                    }
                    if (mapView != null) {
                        if (userLocation != null) {
                            userLocation.setLatitude(mapView.getMapCenter().getLatitude());
                            userLocation.setLongitude(mapView.getMapCenter().getLongitude());
                        }
                    }
                    adapter.setCustomLocation(userLocation);
                }
            }
            return super.onTouchEvent(ev);
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            AndroidUtilities.runOnUIThread(() -> {
                if (moveToBounds != null) {
                    mapView.zoomToBoundingBox(moveToBounds, false, AndroidUtilities.dp(80 + 33));
                    moveToBounds = null;
                }
            });
        }
    };
    AndroidUtilities.runOnUIThread(() -> {
        if (mapView != null && getParentActivity() != null) {
            mapView.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10));
            onMapInit();
            mapsInitialized = true;
            if (isActiveThemeDark()) {
            /*currentMapStyleDark = true;
                    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(ApplicationLoader.applicationContext, R.raw.mapstyle_night);
                    googleMap.setMapStyle(style);
                    */
            // TODO Dark?
            }
            if (onResumeCalled) {
                mapView.onResume();
            }
        }
    });
    if (messageObject == null && chatLocation == null) {
        if (chat != null && locationType == LOCATION_TYPE_GROUP && dialogId != 0) {
            FrameLayout frameLayout1 = new FrameLayout(context);
            frameLayout1.setBackgroundResource(R.drawable.livepin);
            mapViewClip.addView(frameLayout1, LayoutHelper.createFrame(62, 76, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
            BackupImageView backupImageView = new BackupImageView(context);
            backupImageView.setRoundRadius(AndroidUtilities.dp(26));
            backupImageView.setForUserOrChat(chat, new AvatarDrawable(chat));
            frameLayout1.addView(backupImageView, LayoutHelper.createFrame(52, 52, Gravity.LEFT | Gravity.TOP, 5, 5, 0, 0));
            markerImageView = frameLayout1;
            markerImageView.setTag(1);
        }
        if (markerImageView == null) {
            ImageView imageView = new ImageView(context);
            imageView.setImageResource(R.drawable.map_pin2);
            mapViewClip.addView(imageView, LayoutHelper.createFrame(28, 48, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
            markerImageView = imageView;
        }
        searchListView = new RecyclerListView(context);
        searchListView.setVisibility(View.GONE);
        searchListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        searchAdapter = new LocationActivitySearchAdapter(context) {

            @Override
            public void notifyDataSetChanged() {
                if (searchItem != null) {
                    searchItem.setShowSearchProgress(searchAdapter.isSearching());
                }
                if (emptySubtitleTextView != null) {
                    emptySubtitleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("NoPlacesFoundInfo", R.string.NoPlacesFoundInfo, searchAdapter.getLastSearchString())));
                }
                super.notifyDataSetChanged();
            }
        };
        searchAdapter.setDelegate(0, places -> {
            searchInProgress = false;
            updateEmptyView();
        });
        frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
        searchListView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                }
            }
        });
        searchListView.setOnItemClickListener((view, position) -> {
            TLRPC.TL_messageMediaVenue object = searchAdapter.getItem(position);
            if (object != null && delegate != null) {
                if (parentFragment != null && parentFragment.isInScheduleMode()) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                        delegate.didSelectLocation(object, locationType, notify, scheduleDate);
                        finishFragment();
                    });
                } else {
                    delegate.didSelectLocation(object, locationType, true, 0);
                    finishFragment();
                }
            }
        });
    } else if (messageObject != null && !messageObject.isLiveLocation() || chatLocation != null) {
        if (chatLocation != null) {
            adapter.setChatLocation(chatLocation);
        } else if (messageObject != null) {
            adapter.setMessageObject(messageObject);
        }
    }
    if (messageObject != null && locationType == LOCATION_TYPE_LIVE_VIEW) {
        adapter.setMessageObject(messageObject);
    }
    for (int a = 0; a < 2; a++) {
        undoView[a] = new UndoView(context);
        undoView[a].setAdditionalTranslationY(AndroidUtilities.dp(10));
        if (Build.VERSION.SDK_INT >= 21) {
            undoView[a].setTranslationZ(AndroidUtilities.dp(5));
        }
        mapViewClip.addView(undoView[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    }
    shadow = new View(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            shadowDrawable.setBounds(-padding.left, 0, getMeasuredWidth() + padding.right, getMeasuredHeight());
            shadowDrawable.draw(canvas);
            if (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE) {
                int w = AndroidUtilities.dp(36);
                int y = padding.top + AndroidUtilities.dp(10);
                rect.set((getMeasuredWidth() - w) / 2, y, (getMeasuredWidth() + w) / 2, y + AndroidUtilities.dp(4));
                int color = Theme.getColor(Theme.key_sheet_scrollUp);
                int alpha = Color.alpha(color);
                Theme.dialogs_onlineCirclePaint.setColor(color);
                canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), Theme.dialogs_onlineCirclePaint);
            }
        }
    };
    if (Build.VERSION.SDK_INT >= 21) {
        shadow.setTranslationZ(AndroidUtilities.dp(6));
    }
    mapViewClip.addView(shadow, layoutParams);
    if (messageObject == null && chatLocation == null && initialLocation != null) {
        userLocationMoved = true;
        locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
        locationButton.setTag(Theme.key_location_actionIcon);
    }
    frameLayout.addView(actionBar);
    updateEmptyView();
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LocationController(org.telegram.messenger.LocationController) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) Manifest(android.Manifest) StateListAnimator(android.animation.StateListAnimator) ITileSource(org.osmdroid.tileprovider.tilesource.ITileSource) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) XYTileSource(org.osmdroid.tileprovider.tilesource.XYTileSource) Configuration(org.osmdroid.config.Configuration) LocationActivitySearchAdapter(org.telegram.ui.Adapters.LocationActivitySearchAdapter) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ScrollEvent(org.osmdroid.events.ScrollEvent) UndoView(org.telegram.ui.Components.UndoView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Polygon(org.osmdroid.views.overlay.Polygon) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) LocationActivityAdapter(org.telegram.ui.Adapters.LocationActivityAdapter) Html(android.text.Html) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) FileLoader(org.telegram.messenger.FileLoader) ZoomEvent(org.osmdroid.events.ZoomEvent) BitmapFactory(android.graphics.BitmapFactory) AlertsCreator(org.telegram.ui.Components.AlertsCreator) ArrayList(java.util.ArrayList) TileSourceFactory(org.osmdroid.tileprovider.tilesource.TileSourceFactory) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) BuildConfig(org.telegram.messenger.BuildConfig) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) MapView(org.osmdroid.views.MapView) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) LocationCell(org.telegram.ui.Cells.LocationCell) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) IMyLocationProvider(org.osmdroid.views.overlay.mylocation.IMyLocationProvider) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) MyLocationNewOverlay(org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) PackageManager(android.content.pm.PackageManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) LinkMovementMethod(android.text.method.LinkMovementMethod) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) Locale(java.util.Locale) View(android.view.View) IMapController(org.osmdroid.api.IMapController) RecyclerView(androidx.recyclerview.widget.RecyclerView) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) BitmapShader(android.graphics.BitmapShader) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) IGeoPoint(org.osmdroid.api.IGeoPoint) GpsMyLocationProvider(org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) Marker(org.osmdroid.views.overlay.Marker) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) ViewGroup(android.view.ViewGroup) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) List(java.util.List) TextView(android.widget.TextView) Location(android.location.Location) ProximitySheet(org.telegram.ui.Components.ProximitySheet) LocationManager(android.location.LocationManager) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) HeaderCell(org.telegram.ui.Cells.HeaderCell) GeoPoint(org.osmdroid.util.GeoPoint) SuppressLint(android.annotation.SuppressLint) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) MapListener(org.osmdroid.events.MapListener) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) Build(android.os.Build) Projection(org.osmdroid.views.Projection) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) BoundingBox(org.osmdroid.util.BoundingBox) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) Activity(android.app.Activity) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LocationActivitySearchAdapter(org.telegram.ui.Adapters.LocationActivitySearchAdapter) Activity(android.app.Activity) LocationController(org.telegram.messenger.LocationController) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) TLRPC(org.telegram.tgnet.TLRPC) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) BackupImageView(org.telegram.ui.Components.BackupImageView) MapView(org.osmdroid.views.MapView) IMapController(org.osmdroid.api.IMapController) TextView(android.widget.TextView) ImageView(android.widget.ImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) EditText(android.widget.EditText) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ITileSource(org.osmdroid.tileprovider.tilesource.ITileSource) UserObject(org.telegram.messenger.UserObject) ChatObject(org.telegram.messenger.ChatObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) StateListAnimator(android.animation.StateListAnimator) LocationActivityAdapter(org.telegram.ui.Adapters.LocationActivityAdapter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AnimatorSet(android.animation.AnimatorSet) RecyclerListView(org.telegram.ui.Components.RecyclerListView) XYTileSource(org.osmdroid.tileprovider.tilesource.XYTileSource) UndoView(org.telegram.ui.Components.UndoView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) Outline(android.graphics.Outline) ImageView(android.widget.ImageView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) MapView(org.osmdroid.views.MapView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewOutlineProvider(android.view.ViewOutlineProvider) Paint(android.graphics.Paint) IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) HintView(org.telegram.ui.Components.HintView) MotionEvent(android.view.MotionEvent) RectF(android.graphics.RectF) FrameLayout(android.widget.FrameLayout) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) ImageLocation(org.telegram.messenger.ImageLocation) Location(android.location.Location)

Example 3 with HintView

use of org.telegram.ui.Components.HintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class GroupCallActivity method showRecordHint.

private void showRecordHint(View view) {
    if (recordHintView == null) {
        recordHintView = new HintView(getContext(), 8, true);
        recordHintView.setAlpha(0.0f);
        recordHintView.setVisibility(View.INVISIBLE);
        recordHintView.setShowingDuration(3000);
        containerView.addView(recordHintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
        if (ChatObject.isChannelOrGiga(currentChat)) {
            recordHintView.setText(LocaleController.getString("VoipChannelRecording", R.string.VoipChannelRecording));
        } else {
            recordHintView.setText(LocaleController.getString("VoipGroupRecording", R.string.VoipGroupRecording));
        }
        recordHintView.setBackgroundColor(0xea272f38, 0xffffffff);
    }
    recordHintView.setExtraTranslationY(-AndroidUtilities.statusBarHeight);
    recordHintView.showForView(view, true);
}
Also used : HintView(org.telegram.ui.Components.HintView)

Example 4 with HintView

use of org.telegram.ui.Components.HintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class GroupCallActivity method showReminderHint.

private void showReminderHint() {
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    if (preferences.getBoolean("reminderhint", false)) {
        return;
    }
    preferences.edit().putBoolean("reminderhint", true).commit();
    if (reminderHintView == null) {
        reminderHintView = new HintView(getContext(), 8);
        reminderHintView.setAlpha(0.0f);
        reminderHintView.setVisibility(View.INVISIBLE);
        reminderHintView.setShowingDuration(4000);
        containerView.addView(reminderHintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
        reminderHintView.setText(LocaleController.getString("VoipChatReminderHint", R.string.VoipChatReminderHint));
        reminderHintView.setBackgroundColor(0xea272f38, 0xffffffff);
    }
    reminderHintView.setExtraTranslationY(-AndroidUtilities.statusBarHeight);
    reminderHintView.showForView(muteButton, true);
}
Also used : SharedPreferences(android.content.SharedPreferences) HintView(org.telegram.ui.Components.HintView)

Example 5 with HintView

use of org.telegram.ui.Components.HintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class ProfileActivity method createView.

@Override
public View createView(Context context) {
    Theme.createProfileResources(context);
    Theme.createChatResources(context, false);
    searchTransitionOffset = 0;
    searchTransitionProgress = 1f;
    searchMode = false;
    hasOwnBackground = true;
    extraHeight = AndroidUtilities.dp(88f);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(final int id) {
            if (getParentActivity() == null) {
                return;
            }
            if (id == -1) {
                finishFragment();
            } else if (id == block_contact) {
                TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null) {
                    return;
                }
                if (!isBot || MessagesController.isSupportUser(user)) {
                    if (userBlocked) {
                        getMessagesController().unblockPeer(userId);
                        if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                            BulletinFactory.createBanBulletin(ProfileActivity.this, false).show();
                        }
                    } else {
                        if (reportSpam) {
                            AlertsCreator.showBlockReportSpamAlert(ProfileActivity.this, userId, user, null, currentEncryptedChat, false, null, param -> {
                                if (param == 1) {
                                    getNotificationCenter().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
                                    getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                                    playProfileAnimation = 0;
                                    finishFragment();
                                } else {
                                    getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, userId);
                                }
                            }, null);
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser));
                            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name))));
                            builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> {
                                getMessagesController().blockPeer(userId);
                                if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                                    BulletinFactory.createBanBulletin(ProfileActivity.this, true).show();
                                }
                            });
                            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                            AlertDialog dialog = builder.create();
                            showDialog(dialog);
                            TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                            if (button != null) {
                                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                            }
                        }
                    }
                } else {
                    if (!userBlocked) {
                        getMessagesController().blockPeer(userId);
                    } else {
                        getMessagesController().unblockPeer(userId);
                        getSendMessagesHelper().sendMessage("/start", userId, null, null, null, false, null, null, null, true, 0, null);
                        finishFragment();
                    }
                }
            } else if (id == add_contact) {
                TLRPC.User user = getMessagesController().getUser(userId);
                Bundle args = new Bundle();
                args.putLong("user_id", user.id);
                args.putBoolean("addContact", true);
                presentFragment(new ContactAddActivity(args));
            } else if (id == share_contact) {
                Bundle args = new Bundle();
                args.putBoolean("onlySelect", true);
                args.putInt("dialogsType", 3);
                args.putString("selectAlertString", LocaleController.getString("SendContactToText", R.string.SendContactToText));
                args.putString("selectAlertStringGroup", LocaleController.getString("SendContactToGroupText", R.string.SendContactToGroupText));
                DialogsActivity fragment = new DialogsActivity(args);
                fragment.setDelegate(ProfileActivity.this);
                presentFragment(fragment);
            } else if (id == edit_contact) {
                Bundle args = new Bundle();
                args.putLong("user_id", userId);
                presentFragment(new ContactAddActivity(args));
            } else if (id == delete_contact) {
                final TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null || getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("DeleteContact", R.string.DeleteContact));
                builder.setMessage(LocaleController.getString("AreYouSureDeleteContact", R.string.AreYouSureDeleteContact));
                builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
                    ArrayList<TLRPC.User> arrayList = new ArrayList<>();
                    arrayList.add(user);
                    getContactsController().deleteContact(arrayList, true);
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                AlertDialog dialog = builder.create();
                showDialog(dialog);
                TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (button != null) {
                    button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                }
            } else if (id == leave_group) {
                leaveChatPressed();
            } else if (id == edit_channel) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                ChatEditActivity fragment = new ChatEditActivity(args);
                fragment.setInfo(chatInfo);
                presentFragment(fragment);
            } else if (id == invite_to_group) {
                final TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null) {
                    return;
                }
                Bundle args = new Bundle();
                args.putBoolean("onlySelect", true);
                args.putInt("dialogsType", 2);
                args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupAlertText", R.string.AddToTheGroupAlertText, UserObject.getUserName(user), "%1$s"));
                DialogsActivity fragment = new DialogsActivity(args);
                fragment.setDelegate((fragment1, dids, message, param) -> {
                    long did = dids.get(0);
                    Bundle args1 = new Bundle();
                    args1.putBoolean("scrollToTopOnResume", true);
                    args1.putLong("chat_id", -did);
                    if (!getMessagesController().checkCanOpenChat(args1, fragment1)) {
                        return;
                    }
                    getNotificationCenter().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
                    getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                    getMessagesController().addUserToChat(-did, user, 0, null, ProfileActivity.this, null);
                    presentFragment(new ChatActivity(args1), true);
                    removeSelfFromStack();
                });
                presentFragment(fragment);
            } else if (id == share) {
                try {
                    String text = null;
                    if (userId != 0) {
                        TLRPC.User user = getMessagesController().getUser(userId);
                        if (user == null) {
                            return;
                        }
                        if (botInfo != null && userInfo != null && !TextUtils.isEmpty(userInfo.about)) {
                            text = String.format("%s https://" + getMessagesController().linkPrefix + "/%s", userInfo.about, user.username);
                        } else {
                            text = String.format("https://" + getMessagesController().linkPrefix + "/%s", user.username);
                        }
                    } else if (chatId != 0) {
                        TLRPC.Chat chat = getMessagesController().getChat(chatId);
                        if (chat == null) {
                            return;
                        }
                        if (chatInfo != null && !TextUtils.isEmpty(chatInfo.about)) {
                            text = String.format("%s\nhttps://" + getMessagesController().linkPrefix + "/%s", chatInfo.about, chat.username);
                        } else {
                            text = String.format("https://" + getMessagesController().linkPrefix + "/%s", chat.username);
                        }
                    }
                    if (TextUtils.isEmpty(text)) {
                        return;
                    }
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/plain");
                    intent.putExtra(Intent.EXTRA_TEXT, text);
                    startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == add_shortcut) {
                try {
                    long did;
                    if (currentEncryptedChat != null) {
                        did = DialogObject.makeEncryptedDialogId(currentEncryptedChat.id);
                    } else if (userId != 0) {
                        did = userId;
                    } else if (chatId != 0) {
                        did = -chatId;
                    } else {
                        return;
                    }
                    getMediaDataController().installShortcut(did);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == call_item || id == video_call_item) {
                if (userId != 0) {
                    TLRPC.User user = getMessagesController().getUser(userId);
                    if (user != null) {
                        VoIPHelper.startCall(user, id == video_call_item, userInfo != null && userInfo.video_calls_available, getParentActivity(), userInfo, getAccountInstance());
                    }
                } else if (chatId != 0) {
                    ChatObject.Call call = getMessagesController().getGroupCall(chatId, false);
                    if (call == null) {
                        VoIPHelper.showGroupCallAlert(ProfileActivity.this, currentChat, null, false, getAccountInstance());
                    } else {
                        VoIPHelper.startCall(currentChat, null, null, false, getParentActivity(), ProfileActivity.this, getAccountInstance());
                    }
                }
            } else if (id == search_members) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putInt("type", ChatUsersActivity.TYPE_USERS);
                args.putBoolean("open_search", true);
                ChatUsersActivity fragment = new ChatUsersActivity(args);
                fragment.setInfo(chatInfo);
                presentFragment(fragment);
            } else if (id == add_member) {
                openAddMember();
            } else if (id == statistics) {
                TLRPC.Chat chat = getMessagesController().getChat(chatId);
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putBoolean("is_megagroup", chat.megagroup);
                StatisticActivity fragment = new StatisticActivity(args);
                presentFragment(fragment);
            } else if (id == view_discussion) {
                openDiscussion();
            } else if (id == start_secret_chat) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AreYouSureSecretChatTitle", R.string.AreYouSureSecretChatTitle));
                builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
                builder.setPositiveButton(LocaleController.getString("Start", R.string.Start), (dialogInterface, i) -> {
                    creatingChat = true;
                    getSecretChatHelper().startSecretChat(getParentActivity(), getMessagesController().getUser(userId));
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (id == gallery_menu_save) {
                if (getParentActivity() == null) {
                    return;
                }
                if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    getParentActivity().requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
                    return;
                }
                ImageLocation location = avatarsViewPager.getImageLocation(avatarsViewPager.getRealPosition());
                if (location == null) {
                    return;
                }
                final boolean isVideo = location.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
                File f = FileLoader.getPathToAttach(location.location, isVideo ? "mp4" : null, true);
                if (f.exists()) {
                    MediaController.saveFile(f.toString(), getParentActivity(), 0, null, null, () -> {
                        if (getParentActivity() == null) {
                            return;
                        }
                        BulletinFactory.createSaveToGalleryBulletin(ProfileActivity.this, isVideo, null).show();
                    });
                }
            } else if (id == edit_name) {
                presentFragment(new ChangeNameActivity());
            } else if (id == logout) {
                presentFragment(new LogoutActivity());
            } else if (id == set_as_main) {
                int position = avatarsViewPager.getRealPosition();
                TLRPC.Photo photo = avatarsViewPager.getPhoto(position);
                if (photo == null) {
                    return;
                }
                avatarsViewPager.startMovePhotoToBegin(position);
                TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto();
                req.id = new TLRPC.TL_inputPhoto();
                req.id.id = photo.id;
                req.id.access_hash = photo.access_hash;
                req.id.file_reference = photo.file_reference;
                UserConfig userConfig = getUserConfig();
                getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    avatarsViewPager.finishSettingMainPhoto();
                    if (response instanceof TLRPC.TL_photos_photo) {
                        TLRPC.TL_photos_photo photos_photo = (TLRPC.TL_photos_photo) response;
                        getMessagesController().putUsers(photos_photo.users, false);
                        TLRPC.User user = getMessagesController().getUser(userConfig.clientUserId);
                        if (photos_photo.photo instanceof TLRPC.TL_photo) {
                            avatarsViewPager.replaceFirstPhoto(photo, photos_photo.photo);
                            if (user != null) {
                                user.photo.photo_id = photos_photo.photo.id;
                                userConfig.setCurrentUser(user);
                                userConfig.saveConfig(true);
                            }
                        }
                    }
                }));
                undoView.showWithAction(userId, UndoView.ACTION_PROFILE_PHOTO_CHANGED, photo.video_sizes.isEmpty() ? null : 1);
                TLRPC.User user = getMessagesController().getUser(userConfig.clientUserId);
                TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 800);
                if (user != null) {
                    TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 90);
                    user.photo.photo_id = photo.id;
                    user.photo.photo_small = smallSize.location;
                    user.photo.photo_big = bigSize.location;
                    userConfig.setCurrentUser(user);
                    userConfig.saveConfig(true);
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
                    updateProfileData();
                }
                avatarsViewPager.commitMoveToBegin();
            } else if (id == edit_avatar) {
                int position = avatarsViewPager.getRealPosition();
                ImageLocation location = avatarsViewPager.getImageLocation(position);
                if (location == null) {
                    return;
                }
                File f = FileLoader.getPathToAttach(PhotoViewer.getFileLocation(location), PhotoViewer.getFileLocationExt(location), true);
                boolean isVideo = location.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
                String thumb;
                if (isVideo) {
                    ImageLocation imageLocation = avatarsViewPager.getRealImageLocation(position);
                    thumb = FileLoader.getPathToAttach(PhotoViewer.getFileLocation(imageLocation), PhotoViewer.getFileLocationExt(imageLocation), true).getAbsolutePath();
                } else {
                    thumb = null;
                }
                imageUpdater.openPhotoForEdit(f.getAbsolutePath(), thumb, 0, isVideo);
            } else if (id == delete_avatar) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                ImageLocation location = avatarsViewPager.getImageLocation(avatarsViewPager.getRealPosition());
                if (location == null) {
                    return;
                }
                if (location.imageType == FileLoader.IMAGE_TYPE_ANIMATION) {
                    builder.setTitle(LocaleController.getString("AreYouSureDeleteVideoTitle", R.string.AreYouSureDeleteVideoTitle));
                    builder.setMessage(LocaleController.formatString("AreYouSureDeleteVideo", R.string.AreYouSureDeleteVideo));
                } else {
                    builder.setTitle(LocaleController.getString("AreYouSureDeletePhotoTitle", R.string.AreYouSureDeletePhotoTitle));
                    builder.setMessage(LocaleController.formatString("AreYouSureDeletePhoto", R.string.AreYouSureDeletePhoto));
                }
                builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
                    int position = avatarsViewPager.getRealPosition();
                    TLRPC.Photo photo = avatarsViewPager.getPhoto(position);
                    if (avatarsViewPager.getRealCount() == 1) {
                        setForegroundImage(true);
                    }
                    if (photo == null || avatarsViewPager.getRealPosition() == 0) {
                        getMessagesController().deleteUserPhoto(null);
                    } else {
                        TLRPC.TL_inputPhoto inputPhoto = new TLRPC.TL_inputPhoto();
                        inputPhoto.id = photo.id;
                        inputPhoto.access_hash = photo.access_hash;
                        inputPhoto.file_reference = photo.file_reference;
                        if (inputPhoto.file_reference == null) {
                            inputPhoto.file_reference = new byte[0];
                        }
                        getMessagesController().deleteUserPhoto(inputPhoto);
                        getMessagesStorage().clearUserPhoto(userId, photo.id);
                    }
                    if (avatarsViewPager.removePhotoAtIndex(position)) {
                        avatarsViewPager.setVisibility(View.GONE);
                        avatarImage.setForegroundAlpha(1f);
                        avatarContainer.setVisibility(View.VISIBLE);
                        doNotSetForeground = true;
                        final View view = layoutManager.findViewByPosition(0);
                        if (view != null) {
                            listView.smoothScrollBy(0, view.getTop() - AndroidUtilities.dp(88), CubicBezierInterpolator.EASE_OUT_QUINT);
                        }
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                AlertDialog alertDialog = builder.create();
                showDialog(alertDialog);
                TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (button != null) {
                    button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                }
            } else if (id == add_photo) {
                onWriteButtonClick();
            } else if (id == qr_button) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putLong("user_id", userId);
                presentFragment(new QrActivity(args));
            }
        }
    });
    if (sharedMediaLayout != null) {
        sharedMediaLayout.onDestroy();
    }
    final long did;
    if (dialogId != 0) {
        did = dialogId;
    } else if (userId != 0) {
        did = userId;
    } else {
        did = -chatId;
    }
    ArrayList<Integer> users = chatInfo != null && chatInfo.participants != null && chatInfo.participants.participants.size() > 5 ? sortedUsers : null;
    sharedMediaLayout = new SharedMediaLayout(context, did, sharedMediaPreloader, userInfo != null ? userInfo.common_chats_count : 0, sortedUsers, chatInfo, users != null, this, this, SharedMediaLayout.VIEW_TYPE_PROFILE_ACTIVITY) {

        @Override
        protected void onSelectedTabChanged() {
            updateSelectedMediaTabText();
        }

        @Override
        protected boolean canShowSearchItem() {
            return mediaHeaderVisible;
        }

        @Override
        protected void onSearchStateChanged(boolean expanded) {
            if (SharedConfig.smoothKeyboard) {
                AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid);
            }
            listView.stopScroll();
            avatarContainer2.setPivotY(avatarContainer.getPivotY() + avatarContainer.getMeasuredHeight() / 2f);
            avatarContainer2.setPivotX(avatarContainer2.getMeasuredWidth() / 2f);
            AndroidUtilities.updateViewVisibilityAnimated(avatarContainer2, !expanded, 0.95f, true);
            callItem.setVisibility(expanded || !callItemVisible ? GONE : INVISIBLE);
            videoCallItem.setVisibility(expanded || !videoCallItemVisible ? GONE : INVISIBLE);
            editItem.setVisibility(expanded || !editItemVisible ? GONE : INVISIBLE);
            otherItem.setVisibility(expanded ? GONE : INVISIBLE);
            if (qrItem != null) {
                qrItem.setVisibility(expanded ? GONE : INVISIBLE);
            }
        }

        @Override
        protected boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong) {
            return ProfileActivity.this.onMemberClick(participant, isLong);
        }
    };
    sharedMediaLayout.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.MATCH_PARENT));
    ActionBarMenu menu = actionBar.createMenu();
    if (userId == getUserConfig().clientUserId) {
        qrItem = menu.addItem(qr_button, R.drawable.msg_qr_mini, getResourceProvider());
        qrItem.setVisibility(isQrNeedVisible() ? View.VISIBLE : View.GONE);
        qrItem.setContentDescription(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
    }
    if (imageUpdater != null) {
        searchItem = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {

            @Override
            public Animator getCustomToggleTransition() {
                searchMode = !searchMode;
                if (!searchMode) {
                    searchItem.clearFocusOnSearchView();
                }
                if (searchMode) {
                    searchItem.getSearchField().setText("");
                }
                return searchExpandTransition(searchMode);
            }

            @Override
            public void onTextChanged(EditText editText) {
                searchAdapter.search(editText.getText().toString().toLowerCase());
            }
        });
        searchItem.setContentDescription(LocaleController.getString("SearchInSettings", R.string.SearchInSettings));
        searchItem.setSearchFieldHint(LocaleController.getString("SearchInSettings", R.string.SearchInSettings));
        sharedMediaLayout.getSearchItem().setVisibility(View.GONE);
        if (expandPhoto) {
            searchItem.setVisibility(View.GONE);
        }
    }
    videoCallItem = menu.addItem(video_call_item, R.drawable.profile_video);
    videoCallItem.setContentDescription(LocaleController.getString("VideoCall", R.string.VideoCall));
    if (chatId != 0) {
        callItem = menu.addItem(call_item, R.drawable.msg_voicechat2);
        if (ChatObject.isChannelOrGiga(currentChat)) {
            callItem.setContentDescription(LocaleController.getString("VoipChannelVoiceChat", R.string.VoipChannelVoiceChat));
        } else {
            callItem.setContentDescription(LocaleController.getString("VoipGroupVoiceChat", R.string.VoipGroupVoiceChat));
        }
    } else {
        callItem = menu.addItem(call_item, R.drawable.ic_call);
        callItem.setContentDescription(LocaleController.getString("Call", R.string.Call));
    }
    editItem = menu.addItem(edit_channel, R.drawable.group_edit_profile);
    editItem.setContentDescription(LocaleController.getString("Edit", R.string.Edit));
    otherItem = menu.addItem(10, R.drawable.ic_ab_other);
    otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    int scrollTo;
    int scrollToPosition = 0;
    Object writeButtonTag = null;
    if (listView != null && imageUpdater != null) {
        scrollTo = layoutManager.findFirstVisibleItemPosition();
        View topView = layoutManager.findViewByPosition(scrollTo);
        if (topView != null) {
            scrollToPosition = topView.getTop() - listView.getPaddingTop();
        } else {
            scrollTo = -1;
        }
        writeButtonTag = writeButton.getTag();
    } else {
        scrollTo = -1;
    }
    createActionBarMenu(false);
    listAdapter = new ListAdapter(context);
    searchAdapter = new SearchAdapter(context);
    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setProfile(true);
    fragmentView = new NestedFrameLayout(context) {

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            if (pinchToZoomHelper.isInOverlayMode()) {
                return pinchToZoomHelper.onTouchEvent(ev);
            }
            if (sharedMediaLayout != null && sharedMediaLayout.isInFastScroll() && sharedMediaLayout.isPinnedToTop()) {
                return sharedMediaLayout.dispatchFastScrollEvent(ev);
            }
            if (sharedMediaLayout != null && sharedMediaLayout.checkPinchToZoom(ev)) {
                return true;
            }
            return super.dispatchTouchEvent(ev);
        }

        private boolean ignoreLayout;

        private Paint grayPaint = new Paint();

        @Override
        public boolean hasOverlappingRendering() {
            return false;
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            final int actionBarHeight = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
            if (listView != null) {
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
                if (layoutParams.topMargin != actionBarHeight) {
                    layoutParams.topMargin = actionBarHeight;
                }
            }
            if (searchListView != null) {
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams();
                if (layoutParams.topMargin != actionBarHeight) {
                    layoutParams.topMargin = actionBarHeight;
                }
            }
            int height = MeasureSpec.getSize(heightMeasureSpec);
            super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
            boolean changed = false;
            if (lastMeasuredContentWidth != getMeasuredWidth() || lastMeasuredContentHeight != getMeasuredHeight()) {
                changed = lastMeasuredContentWidth != 0 && lastMeasuredContentWidth != getMeasuredWidth();
                listContentHeight = 0;
                int count = listAdapter.getItemCount();
                lastMeasuredContentWidth = getMeasuredWidth();
                lastMeasuredContentHeight = getMeasuredHeight();
                int ws = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
                int hs = MeasureSpec.makeMeasureSpec(listView.getMeasuredHeight(), MeasureSpec.UNSPECIFIED);
                positionToOffset.clear();
                for (int i = 0; i < count; i++) {
                    int type = listAdapter.getItemViewType(i);
                    positionToOffset.put(i, listContentHeight);
                    if (type == 13) {
                        listContentHeight += listView.getMeasuredHeight();
                    } else {
                        RecyclerView.ViewHolder holder = listAdapter.createViewHolder(null, type);
                        listAdapter.onBindViewHolder(holder, i);
                        holder.itemView.measure(ws, hs);
                        listContentHeight += holder.itemView.getMeasuredHeight();
                    }
                }
                if (emptyView != null) {
                    ((LayoutParams) emptyView.getLayoutParams()).topMargin = AndroidUtilities.dp(88) + AndroidUtilities.statusBarHeight;
                }
            }
            if (!fragmentOpened && (expandPhoto || openAnimationInProgress && playProfileAnimation == 2)) {
                ignoreLayout = true;
                if (expandPhoto) {
                    if (searchItem != null) {
                        searchItem.setAlpha(0.0f);
                        searchItem.setEnabled(false);
                        searchItem.setVisibility(GONE);
                    }
                    nameTextView[1].setTextColor(Color.WHITE);
                    onlineTextView[1].setTextColor(Color.argb(179, 255, 255, 255));
                    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, false);
                    actionBar.setItemsColor(Color.WHITE, false);
                    overlaysView.setOverlaysVisible();
                    overlaysView.setAlphaValue(1.0f, false);
                    avatarImage.setForegroundAlpha(1.0f);
                    avatarContainer.setVisibility(View.GONE);
                    avatarsViewPager.resetCurrentItem();
                    avatarsViewPager.setVisibility(View.VISIBLE);
                    expandPhoto = false;
                }
                allowPullingDown = true;
                isPulledDown = true;
                if (otherItem != null) {
                    if (!getMessagesController().isChatNoForwards(currentChat)) {
                        otherItem.showSubItem(gallery_menu_save);
                    } else {
                        otherItem.hideSubItem(gallery_menu_save);
                    }
                    if (imageUpdater != null) {
                        otherItem.showSubItem(edit_avatar);
                        otherItem.showSubItem(delete_avatar);
                        otherItem.hideSubItem(logout);
                    }
                }
                currentExpanAnimatorFracture = 1.0f;
                int paddingTop;
                int paddingBottom;
                if (isInLandscapeMode) {
                    paddingTop = AndroidUtilities.dp(88f);
                    paddingBottom = 0;
                } else {
                    paddingTop = listView.getMeasuredWidth();
                    paddingBottom = Math.max(0, getMeasuredHeight() - (listContentHeight + AndroidUtilities.dp(88) + actionBarHeight));
                }
                if (banFromGroup != 0) {
                    paddingBottom += AndroidUtilities.dp(48);
                    listView.setBottomGlowOffset(AndroidUtilities.dp(48));
                } else {
                    listView.setBottomGlowOffset(0);
                }
                initialAnimationExtraHeight = paddingTop - actionBarHeight;
                layoutManager.scrollToPositionWithOffset(0, -actionBarHeight);
                listView.setPadding(0, paddingTop, 0, paddingBottom);
                measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0);
                listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight());
                ignoreLayout = false;
            } else if (fragmentOpened && !openAnimationInProgress && !firstLayout) {
                ignoreLayout = true;
                int paddingTop;
                int paddingBottom;
                if (isInLandscapeMode || AndroidUtilities.isTablet()) {
                    paddingTop = AndroidUtilities.dp(88f);
                    paddingBottom = 0;
                } else {
                    paddingTop = listView.getMeasuredWidth();
                    paddingBottom = Math.max(0, getMeasuredHeight() - (listContentHeight + AndroidUtilities.dp(88) + actionBarHeight));
                }
                if (banFromGroup != 0) {
                    paddingBottom += AndroidUtilities.dp(48);
                    listView.setBottomGlowOffset(AndroidUtilities.dp(48));
                } else {
                    listView.setBottomGlowOffset(0);
                }
                int currentPaddingTop = listView.getPaddingTop();
                View view = null;
                int pos = RecyclerView.NO_POSITION;
                for (int i = 0; i < listView.getChildCount(); i++) {
                    int p = listView.getChildAdapterPosition(listView.getChildAt(i));
                    if (p != RecyclerView.NO_POSITION) {
                        view = listView.getChildAt(i);
                        pos = p;
                        break;
                    }
                }
                if (view == null) {
                    view = listView.getChildAt(0);
                    if (view != null) {
                        RecyclerView.ViewHolder holder = listView.findContainingViewHolder(view);
                        pos = holder.getAdapterPosition();
                        if (pos == RecyclerView.NO_POSITION) {
                            pos = holder.getPosition();
                        }
                    }
                }
                int top = paddingTop;
                if (view != null) {
                    top = view.getTop();
                }
                boolean layout = false;
                if (actionBar.isSearchFieldVisible() && sharedMediaRow >= 0) {
                    layoutManager.scrollToPositionWithOffset(sharedMediaRow, -paddingTop);
                    layout = true;
                } else if (invalidateScroll || currentPaddingTop != paddingTop) {
                    if (savedScrollPosition >= 0) {
                        layoutManager.scrollToPositionWithOffset(savedScrollPosition, savedScrollOffset - paddingTop);
                    } else if ((!changed || !allowPullingDown) && view != null) {
                        if (pos == 0 && !allowPullingDown && top > AndroidUtilities.dp(88)) {
                            top = AndroidUtilities.dp(88);
                        }
                        layoutManager.scrollToPositionWithOffset(pos, top - paddingTop);
                        layout = true;
                    } else {
                        layoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(88) - paddingTop);
                    }
                }
                if (currentPaddingTop != paddingTop || listView.getPaddingBottom() != paddingBottom) {
                    listView.setPadding(0, paddingTop, 0, paddingBottom);
                    layout = true;
                }
                if (layout) {
                    measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0);
                    try {
                        listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight());
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                ignoreLayout = false;
            }
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            savedScrollPosition = -1;
            firstLayout = false;
            invalidateScroll = false;
            checkListViewScroll();
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }

        private final ArrayList<View> sortedChildren = new ArrayList<>();

        private final Comparator<View> viewComparator = (view, view2) -> (int) (view.getY() - view2.getY());

        @Override
        protected void dispatchDraw(Canvas canvas) {
            whitePaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
            if (listView.getVisibility() == VISIBLE) {
                grayPaint.setColor(Theme.getColor(Theme.key_windowBackgroundGray));
                if (transitionAnimationInProress) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha()));
                }
                if (transitionAnimationInProress) {
                    grayPaint.setAlpha((int) (255 * listView.getAlpha()));
                }
                int count = listView.getChildCount();
                sortedChildren.clear();
                boolean hasRemovingItems = false;
                for (int i = 0; i < count; i++) {
                    View child = listView.getChildAt(i);
                    if (listView.getChildAdapterPosition(child) != RecyclerView.NO_POSITION) {
                        sortedChildren.add(listView.getChildAt(i));
                    } else {
                        hasRemovingItems = true;
                    }
                }
                Collections.sort(sortedChildren, viewComparator);
                boolean hasBackground = false;
                float lastY = listView.getY();
                count = sortedChildren.size();
                if (!openAnimationInProgress && count > 0 && !hasRemovingItems) {
                    lastY += sortedChildren.get(0).getY();
                }
                float alpha = 1f;
                for (int i = 0; i < count; i++) {
                    View child = sortedChildren.get(i);
                    boolean currentHasBackground = child.getBackground() != null;
                    int currentY = (int) (listView.getY() + child.getY());
                    if (hasBackground == currentHasBackground) {
                        if (child.getAlpha() == 1f) {
                            alpha = 1f;
                        }
                        continue;
                    }
                    if (hasBackground) {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, grayPaint);
                    } else {
                        if (alpha != 1f) {
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, grayPaint);
                            whitePaint.setAlpha((int) (255 * alpha));
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, whitePaint);
                            whitePaint.setAlpha(255);
                        } else {
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, whitePaint);
                        }
                    }
                    hasBackground = currentHasBackground;
                    lastY = currentY;
                    alpha = child.getAlpha();
                }
                if (hasBackground) {
                    canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), grayPaint);
                } else {
                    if (alpha != 1f) {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), grayPaint);
                        whitePaint.setAlpha((int) (255 * alpha));
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), whitePaint);
                        whitePaint.setAlpha(255);
                    } else {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), whitePaint);
                    }
                }
            } else {
                int top = searchListView.getTop();
                canvas.drawRect(0, top + extraHeight + searchTransitionOffset, getMeasuredWidth(), top + getMeasuredHeight(), whitePaint);
            }
            super.dispatchDraw(canvas);
            if (profileTransitionInProgress && parentLayout.fragmentsStack.size() > 1) {
                BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
                if (fragment instanceof ChatActivity) {
                    ChatActivity chatActivity = (ChatActivity) fragment;
                    FragmentContextView fragmentContextView = chatActivity.getFragmentContextView();
                    if (fragmentContextView != null && fragmentContextView.isCallStyle()) {
                        float progress = extraHeight / AndroidUtilities.dpf2(fragmentContextView.getStyleHeight());
                        if (progress > 1f) {
                            progress = 1f;
                        }
                        canvas.save();
                        canvas.translate(fragmentContextView.getX(), fragmentContextView.getY());
                        fragmentContextView.setDrawOverlay(true);
                        fragmentContextView.setCollapseTransition(true, extraHeight, progress);
                        fragmentContextView.draw(canvas);
                        fragmentContextView.setCollapseTransition(false, extraHeight, progress);
                        fragmentContextView.setDrawOverlay(false);
                        canvas.restore();
                    }
                }
            }
            if (scrimPaint.getAlpha() > 0) {
                canvas.drawRect(0, 0, getWidth(), getHeight(), scrimPaint);
            }
            if (scrimView != null) {
                int c = canvas.save();
                canvas.translate(scrimView.getLeft(), scrimView.getTop());
                if (scrimView == actionBar.getBackButton()) {
                    int r = Math.max(scrimView.getMeasuredWidth(), scrimView.getMeasuredHeight()) / 2;
                    int wasAlpha = actionBarBackgroundPaint.getAlpha();
                    actionBarBackgroundPaint.setAlpha((int) (wasAlpha * (scrimPaint.getAlpha() / 255f) / 0.3f));
                    canvas.drawCircle(r, r, r * 0.8f, actionBarBackgroundPaint);
                    actionBarBackgroundPaint.setAlpha(wasAlpha);
                }
                scrimView.draw(canvas);
                canvas.restoreToCount(c);
            }
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (pinchToZoomHelper.isInOverlayMode() && (child == avatarContainer2 || child == actionBar || child == writeButton)) {
                return true;
            }
            return super.drawChild(canvas, child, drawingTime);
        }
    };
    fragmentView.setWillNotDraw(false);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    listView = new RecyclerListView(context) {

        private VelocityTracker velocityTracker;

        @Override
        protected boolean canHighlightChildAt(View child, float x, float y) {
            return !(child instanceof AboutLinkCell);
        }

        @Override
        protected boolean allowSelectChildAtPosition(View child) {
            return child != sharedMediaLayout;
        }

        @Override
        public boolean hasOverlappingRendering() {
            return false;
        }

        @Override
        protected void requestChildOnScreen(View child, View focused) {
        }

        @Override
        public void invalidate() {
            super.invalidate();
            if (fragmentView != null) {
                fragmentView.invalidate();
            }
        }

        @Override
        public boolean onTouchEvent(MotionEvent e) {
            final int action = e.getAction();
            if (action == MotionEvent.ACTION_DOWN) {
                if (velocityTracker == null) {
                    velocityTracker = VelocityTracker.obtain();
                } else {
                    velocityTracker.clear();
                }
                velocityTracker.addMovement(e);
            } else if (action == MotionEvent.ACTION_MOVE) {
                if (velocityTracker != null) {
                    velocityTracker.addMovement(e);
                    velocityTracker.computeCurrentVelocity(1000);
                    listViewVelocityY = velocityTracker.getYVelocity(e.getPointerId(e.getActionIndex()));
                }
            } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                if (velocityTracker != null) {
                    velocityTracker.recycle();
                    velocityTracker = null;
                }
            }
            final boolean result = super.onTouchEvent(e);
            if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                if (allowPullingDown) {
                    final View view = layoutManager.findViewByPosition(0);
                    if (view != null) {
                        if (isPulledDown) {
                            final int actionBarHeight = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
                            listView.smoothScrollBy(0, view.getTop() - listView.getMeasuredWidth() + actionBarHeight, CubicBezierInterpolator.EASE_OUT_QUINT);
                        } else {
                            listView.smoothScrollBy(0, view.getTop() - AndroidUtilities.dp(88), CubicBezierInterpolator.EASE_OUT_QUINT);
                        }
                    }
                }
            }
            return result;
        }

        @Override
        public boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (getItemAnimator().isRunning() && child.getBackground() == null && child.getTranslationY() != 0) {
                boolean useAlpha = listView.getChildAdapterPosition(child) == sharedMediaRow && child.getAlpha() != 1f;
                if (useAlpha) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha() * child.getAlpha()));
                }
                canvas.drawRect(listView.getX(), child.getY(), listView.getX() + listView.getMeasuredWidth(), child.getY() + child.getHeight(), whitePaint);
                if (useAlpha) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha()));
                }
            }
            return super.drawChild(canvas, child, drawingTime);
        }
    };
    listView.setVerticalScrollBarEnabled(false);
    DefaultItemAnimator defaultItemAnimator = new DefaultItemAnimator() {

        int animationIndex = -1;

        @Override
        protected void onAllAnimationsDone() {
            super.onAllAnimationsDone();
            getNotificationCenter().onAnimationFinish(animationIndex);
        }

        @Override
        public void runPendingAnimations() {
            boolean removalsPending = !mPendingRemovals.isEmpty();
            boolean movesPending = !mPendingMoves.isEmpty();
            boolean changesPending = !mPendingChanges.isEmpty();
            boolean additionsPending = !mPendingAdditions.isEmpty();
            if (removalsPending || movesPending || additionsPending || changesPending) {
                ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f);
                valueAnimator.addUpdateListener(valueAnimator1 -> listView.invalidate());
                valueAnimator.setDuration(getMoveDuration());
                valueAnimator.start();
                animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
            }
            super.runPendingAnimations();
        }

        @Override
        protected long getAddAnimationDelay(long removeDuration, long moveDuration, long changeDuration) {
            return 0;
        }

        @Override
        protected long getMoveAnimationDelay() {
            return 0;
        }

        @Override
        public long getMoveDuration() {
            return 220;
        }

        @Override
        public long getRemoveDuration() {
            return 220;
        }

        @Override
        public long getAddDuration() {
            return 220;
        }
    };
    listView.setItemAnimator(defaultItemAnimator);
    defaultItemAnimator.setSupportsChangeAnimations(false);
    defaultItemAnimator.setDelayAnimations(false);
    listView.setClipToPadding(false);
    listView.setHideIfEmpty(false);
    layoutManager = new LinearLayoutManager(context) {

        @Override
        public boolean supportsPredictiveItemAnimations() {
            return imageUpdater != null;
        }

        @Override
        public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
            final View view = layoutManager.findViewByPosition(0);
            if (view != null && !openingAvatar) {
                final int canScroll = view.getTop() - AndroidUtilities.dp(88);
                if (!allowPullingDown && canScroll > dy) {
                    dy = canScroll;
                    if (avatarsViewPager.hasImages() && avatarImage.getImageReceiver().hasNotThumb() && !isInLandscapeMode && !AndroidUtilities.isTablet()) {
                        allowPullingDown = avatarBig == null;
                    }
                } else if (allowPullingDown) {
                    if (dy >= canScroll) {
                        dy = canScroll;
                        allowPullingDown = false;
                    } else if (listView.getScrollState() == RecyclerListView.SCROLL_STATE_DRAGGING) {
                        if (!isPulledDown) {
                            dy /= 2;
                        }
                    }
                }
            }
            return super.scrollVerticallyBy(dy, recycler, state);
        }
    };
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.mIgnoreTopPadding = false;
    listView.setLayoutManager(layoutManager);
    listView.setGlowColor(0);
    listView.setAdapter(listAdapter);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    listView.setOnItemClickListener((view, position, x, y) -> {
        if (getParentActivity() == null) {
            return;
        }
        if (position == settingsKeyRow) {
            Bundle args = new Bundle();
            args.putInt("chat_id", DialogObject.getEncryptedChatId(dialogId));
            presentFragment(new IdenticonActivity(args));
        } else if (position == settingsTimerRow) {
            showDialog(AlertsCreator.createTTLAlert(getParentActivity(), currentEncryptedChat, null).create());
        } else if (position == notificationsRow) {
            if (LocaleController.isRTL && x <= AndroidUtilities.dp(76) || !LocaleController.isRTL && x >= view.getMeasuredWidth() - AndroidUtilities.dp(76)) {
                NotificationsCheckCell checkCell = (NotificationsCheckCell) view;
                boolean checked = !checkCell.isChecked();
                boolean defaultEnabled = getNotificationsController().isGlobalNotificationsEnabled(did);
                if (checked) {
                    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                    SharedPreferences.Editor editor = preferences.edit();
                    if (defaultEnabled) {
                        editor.remove("notify2_" + did);
                    } else {
                        editor.putInt("notify2_" + did, 0);
                    }
                    getMessagesStorage().setDialogFlags(did, 0);
                    editor.commit();
                    TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(did);
                    if (dialog != null) {
                        dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                    }
                } else {
                    int untilTime = Integer.MAX_VALUE;
                    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                    SharedPreferences.Editor editor = preferences.edit();
                    long flags;
                    if (!defaultEnabled) {
                        editor.remove("notify2_" + did);
                        flags = 0;
                    } else {
                        editor.putInt("notify2_" + did, 2);
                        flags = 1;
                    }
                    getNotificationsController().removeNotificationsForDialog(did);
                    getMessagesStorage().setDialogFlags(did, flags);
                    editor.commit();
                    TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(did);
                    if (dialog != null) {
                        dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                        if (defaultEnabled) {
                            dialog.notify_settings.mute_until = untilTime;
                        }
                    }
                }
                getNotificationsController().updateServerNotificationsSettings(did);
                checkCell.setChecked(checked);
                RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findViewHolderForPosition(notificationsRow);
                if (holder != null) {
                    listAdapter.onBindViewHolder(holder, notificationsRow);
                }
                return;
            }
            AlertsCreator.showCustomNotificationsDialog(ProfileActivity.this, did, -1, null, currentAccount, param -> listAdapter.notifyItemChanged(notificationsRow));
        } else if (position == unblockRow) {
            getMessagesController().unblockPeer(userId);
            if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                BulletinFactory.createBanBulletin(ProfileActivity.this, false).show();
            }
        } else if (position == sendMessageRow) {
            onWriteButtonClick();
        } else if (position == reportRow) {
            AlertsCreator.createReportAlert(getParentActivity(), getDialogId(), 0, ProfileActivity.this, null);
        } else if (position >= membersStartRow && position < membersEndRow) {
            TLRPC.ChatParticipant participant;
            if (!sortedUsers.isEmpty()) {
                participant = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow));
            } else {
                participant = chatInfo.participants.participants.get(position - membersStartRow);
            }
            onMemberClick(participant, false);
        } else if (position == addMemberRow) {
            openAddMember();
        } else if (position == usernameRow) {
            if (currentChat != null) {
                try {
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/plain");
                    if (!TextUtils.isEmpty(chatInfo.about)) {
                        intent.putExtra(Intent.EXTRA_TEXT, currentChat.title + "\n" + chatInfo.about + "\nhttps://" + getMessagesController().linkPrefix + "/" + currentChat.username);
                    } else {
                        intent.putExtra(Intent.EXTRA_TEXT, currentChat.title + "\nhttps://" + getMessagesController().linkPrefix + "/" + currentChat.username);
                    }
                    getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        } else if (position == locationRow) {
            if (chatInfo.location instanceof TLRPC.TL_channelLocation) {
                LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP_VIEW);
                fragment.setChatLocation(chatId, (TLRPC.TL_channelLocation) chatInfo.location);
                presentFragment(fragment);
            }
        } else if (position == joinRow) {
            getMessagesController().addUserToChat(currentChat.id, getUserConfig().getCurrentUser(), 0, null, ProfileActivity.this, null);
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeSearchByActiveAction);
        } else if (position == subscribersRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_USERS);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == subscribersRequestsRow) {
            MemberRequestsActivity activity = new MemberRequestsActivity(chatId);
            presentFragment(activity);
        } else if (position == administratorsRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_ADMIN);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == blockedUsersRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_BANNED);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == notificationRow) {
            presentFragment(new NotificationsSettingsActivity());
        } else if (position == privacyRow) {
            presentFragment(new PrivacySettingsActivity());
        } else if (position == dataRow) {
            presentFragment(new DataSettingsActivity());
        } else if (position == chatRow) {
            presentFragment(new ThemeActivity(ThemeActivity.THEME_TYPE_BASIC));
        } else if (position == filtersRow) {
            presentFragment(new FiltersSetupActivity());
        } else if (position == devicesRow) {
            presentFragment(new SessionsActivity(0));
        } else if (position == questionRow) {
            showDialog(AlertsCreator.createSupportAlert(ProfileActivity.this));
        } else if (position == faqRow) {
            Browser.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
        } else if (position == policyRow) {
            Browser.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl));
        } else if (position == sendLogsRow) {
            sendLogs(false);
        } else if (position == sendLastLogsRow) {
            sendLogs(true);
        } else if (position == clearLogsRow) {
            FileLog.cleanupLogs();
        } else if (position == switchBackendRow) {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
            builder1.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
            builder1.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
                SharedConfig.pushAuthKey = null;
                SharedConfig.pushAuthKeyId = null;
                SharedConfig.saveConfig();
                getConnectionsManager().switchBackend(true);
            });
            builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder1.create());
        } else if (position == languageRow) {
            presentFragment(new LanguageSelectActivity());
        } else if (position == setUsernameRow) {
            presentFragment(new ChangeUsernameActivity());
        } else if (position == bioRow) {
            if (userInfo != null) {
                presentFragment(new ChangeBioActivity());
            }
        } else if (position == numberRow) {
            presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_CHANGE_PHONE_NUMBER));
        } else if (position == setAvatarRow) {
            onWriteButtonClick();
        } else {
            processOnClickOrPress(position, view);
        }
    });
    listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {

        private int pressCount = 0;

        @Override
        public boolean onItemClick(View view, int position) {
            if (position == versionRow) {
                pressCount++;
                if (pressCount >= 2 || BuildVars.DEBUG_PRIVATE_VERSION) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle(LocaleController.getString("DebugMenu", R.string.DebugMenu));
                    CharSequence[] items;
                    items = new CharSequence[] { LocaleController.getString("DebugMenuImportContacts", R.string.DebugMenuImportContacts), LocaleController.getString("DebugMenuReloadContacts", R.string.DebugMenuReloadContacts), LocaleController.getString("DebugMenuResetContacts", R.string.DebugMenuResetContacts), LocaleController.getString("DebugMenuResetDialogs", R.string.DebugMenuResetDialogs), BuildVars.DEBUG_VERSION ? null : (BuildVars.LOGS_ENABLED ? LocaleController.getString("DebugMenuDisableLogs", R.string.DebugMenuDisableLogs) : LocaleController.getString("DebugMenuEnableLogs", R.string.DebugMenuEnableLogs)), SharedConfig.inappCamera ? LocaleController.getString("DebugMenuDisableCamera", R.string.DebugMenuDisableCamera) : LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), LocaleController.getString("DebugMenuClearMediaCache", R.string.DebugMenuClearMediaCache), LocaleController.getString("DebugMenuCallSettings", R.string.DebugMenuCallSettings), null, BuildVars.DEBUG_PRIVATE_VERSION || BuildVars.isStandaloneApp() ? LocaleController.getString("DebugMenuCheckAppUpdate", R.string.DebugMenuCheckAppUpdate) : null, LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs), SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() && Build.VERSION.SDK_INT >= 23 ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null, BuildVars.DEBUG_PRIVATE_VERSION ? (SharedConfig.disableVoiceAudioEffects ? "Enable voip audio effects" : "Disable voip audio effects") : null, Build.VERSION.SDK_INT >= 21 ? (SharedConfig.noStatusBar ? "Show status bar background" : "Hide status bar background") : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Clean app update" : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Reset suggestions" : null };
                    builder.setItems(items, (dialog, which) -> {
                        if (which == 0) {
                            getUserConfig().syncContacts = true;
                            getUserConfig().saveConfig(false);
                            getContactsController().forceImportContacts();
                        } else if (which == 1) {
                            getContactsController().loadContacts(false, 0);
                        } else if (which == 2) {
                            getContactsController().resetImportedContacts();
                        } else if (which == 3) {
                            getMessagesController().forceResetDialogs();
                        } else if (which == 4) {
                            BuildVars.LOGS_ENABLED = !BuildVars.LOGS_ENABLED;
                            SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
                            sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).commit();
                            updateRowsIds();
                            listAdapter.notifyDataSetChanged();
                        } else if (which == 5) {
                            SharedConfig.toggleInappCamera();
                        } else if (which == 6) {
                            getMessagesStorage().clearSentMedia();
                            SharedConfig.setNoSoundHintShowed(false);
                            SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
                            editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("reminderhint").remove("soundHint").remove("themehint").remove("bganimationhint").remove("filterhint").commit();
                            MessagesController.getEmojiSettings(currentAccount).edit().remove("featured_hidden").commit();
                            SharedConfig.textSelectionHintShows = 0;
                            SharedConfig.lockRecordAudioVideoHint = 0;
                            SharedConfig.stickersReorderingHintUsed = false;
                            SharedConfig.forwardingOptionsHintShown = false;
                            SharedConfig.messageSeenHintCount = 3;
                            SharedConfig.emojiInteractionsHintCount = 3;
                            SharedConfig.dayNightThemeSwitchHintCount = 3;
                            SharedConfig.fastScrollHintCount = 3;
                            ChatThemeController.getInstance(currentAccount).clearCache();
                        } else if (which == 7) {
                            VoIPHelper.showCallDebugSettings(getParentActivity());
                        } else if (which == 8) {
                            SharedConfig.toggleRoundCamera16to9();
                        } else if (which == 9) {
                            ((LaunchActivity) getParentActivity()).checkAppUpdate(true);
                        } else if (which == 10) {
                            getMessagesStorage().readAllDialogs(-1);
                        } else if (which == 11) {
                            SharedConfig.togglePauseMusicOnRecord();
                        } else if (which == 12) {
                            SharedConfig.toggleSmoothKeyboard();
                            if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
                                getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                            }
                        } else if (which == 13) {
                            SharedConfig.toggleDisableVoiceAudioEffects();
                        } else if (which == 14) {
                            SharedConfig.toggleNoStatusBar();
                            if (getParentActivity() != null && Build.VERSION.SDK_INT >= 21) {
                                if (SharedConfig.noStatusBar) {
                                    getParentActivity().getWindow().setStatusBarColor(0);
                                } else {
                                    getParentActivity().getWindow().setStatusBarColor(0x33000000);
                                }
                            }
                        } else if (which == 15) {
                            SharedConfig.pendingAppUpdate = null;
                            SharedConfig.saveConfig();
                            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.appUpdateAvailable);
                        } else if (which == 16) {
                            Set<String> suggestions = getMessagesController().pendingSuggestions;
                            suggestions.add("VALIDATE_PHONE_NUMBER");
                            suggestions.add("VALIDATE_PASSWORD");
                            getNotificationCenter().postNotificationName(NotificationCenter.newSuggestionsAvailable);
                        }
                    });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showDialog(builder.create());
                } else {
                    try {
                        Toast.makeText(getParentActivity(), "¯\\_(ツ)_/¯", Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                return true;
            } else if (position >= membersStartRow && position < membersEndRow) {
                final TLRPC.ChatParticipant participant;
                if (!sortedUsers.isEmpty()) {
                    participant = visibleChatParticipants.get(sortedUsers.get(position - membersStartRow));
                } else {
                    participant = visibleChatParticipants.get(position - membersStartRow);
                }
                return onMemberClick(participant, true);
            } else {
                return processOnClickOrPress(position, view);
            }
        }
    });
    if (searchItem != null) {
        searchListView = new RecyclerListView(context);
        searchListView.setVerticalScrollBarEnabled(false);
        searchListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        searchListView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
        searchListView.setAdapter(searchAdapter);
        searchListView.setItemAnimator(null);
        searchListView.setVisibility(View.GONE);
        searchListView.setLayoutAnimation(null);
        searchListView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
        searchListView.setOnItemClickListener((view, position) -> {
            if (position < 0) {
                return;
            }
            Object object = numberRow;
            boolean add = true;
            if (searchAdapter.searchWas) {
                if (position < searchAdapter.searchResults.size()) {
                    object = searchAdapter.searchResults.get(position);
                } else {
                    position -= searchAdapter.searchResults.size() + 1;
                    if (position >= 0 && position < searchAdapter.faqSearchResults.size()) {
                        object = searchAdapter.faqSearchResults.get(position);
                    }
                }
            } else {
                if (!searchAdapter.recentSearches.isEmpty()) {
                    position--;
                }
                if (position >= 0 && position < searchAdapter.recentSearches.size()) {
                    object = searchAdapter.recentSearches.get(position);
                } else {
                    position -= searchAdapter.recentSearches.size() + 1;
                    if (position >= 0 && position < searchAdapter.faqSearchArray.size()) {
                        object = searchAdapter.faqSearchArray.get(position);
                        add = false;
                    }
                }
            }
            if (object instanceof SearchAdapter.SearchResult) {
                SearchAdapter.SearchResult result = (SearchAdapter.SearchResult) object;
                result.open();
            } else if (object instanceof MessagesController.FaqSearchResult) {
                MessagesController.FaqSearchResult result = (MessagesController.FaqSearchResult) object;
                NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.openArticle, searchAdapter.faqWebPage, result.url);
            }
            if (add && object != null) {
                searchAdapter.addRecent(object);
            }
        });
        searchListView.setOnItemLongClickListener((view, position) -> {
            if (searchAdapter.isSearchWas() || searchAdapter.recentSearches.isEmpty()) {
                return false;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.getString("ClearSearch", R.string.ClearSearch));
            builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> searchAdapter.clearRecent());
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return true;
        });
        searchListView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                }
            }
        });
        searchListView.setAnimateEmptyView(true, 1);
        emptyView = new StickerEmptyView(context, null, 1);
        emptyView.setAnimateLayoutChange(true);
        emptyView.subtitle.setVisibility(View.GONE);
        emptyView.setVisibility(View.GONE);
        frameLayout.addView(emptyView);
        searchAdapter.loadFaqWebPage();
    }
    if (banFromGroup != 0) {
        TLRPC.Chat chat = getMessagesController().getChat(banFromGroup);
        if (currentChannelParticipant == null) {
            TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant();
            req.channel = MessagesController.getInputChannel(chat);
            req.participant = getMessagesController().getInputPeer(userId);
            getConnectionsManager().sendRequest(req, (response, error) -> {
                if (response != null) {
                    AndroidUtilities.runOnUIThread(() -> currentChannelParticipant = ((TLRPC.TL_channels_channelParticipant) response).participant);
                }
            });
        }
        FrameLayout frameLayout1 = new FrameLayout(context) {

            @Override
            protected void onDraw(Canvas canvas) {
                int bottom = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
                Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), bottom);
                Theme.chat_composeShadowDrawable.draw(canvas);
                canvas.drawRect(0, bottom, getMeasuredWidth(), getMeasuredHeight(), Theme.chat_composeBackgroundPaint);
            }
        };
        frameLayout1.setWillNotDraw(false);
        frameLayout.addView(frameLayout1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.LEFT | Gravity.BOTTOM));
        frameLayout1.setOnClickListener(v -> {
            ChatRightsEditActivity fragment = new ChatRightsEditActivity(userId, banFromGroup, null, chat.default_banned_rights, currentChannelParticipant != null ? currentChannelParticipant.banned_rights : null, "", ChatRightsEditActivity.TYPE_BANNED, true, false);
            fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {

                @Override
                public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank) {
                    removeSelfFromStack();
                }

                @Override
                public void didChangeOwner(TLRPC.User user) {
                    undoView.showWithAction(-chatId, currentChat.megagroup ? UndoView.ACTION_OWNER_TRANSFERED_GROUP : UndoView.ACTION_OWNER_TRANSFERED_CHANNEL, user);
                }
            });
            presentFragment(fragment);
        });
        TextView textView = new TextView(context);
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        textView.setGravity(Gravity.CENTER);
        textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        textView.setText(LocaleController.getString("BanFromTheGroup", R.string.BanFromTheGroup));
        frameLayout1.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 1, 0, 0));
        listView.setPadding(0, AndroidUtilities.dp(88), 0, AndroidUtilities.dp(48));
        listView.setBottomGlowOffset(AndroidUtilities.dp(48));
    } else {
        listView.setPadding(0, AndroidUtilities.dp(88), 0, 0);
    }
    topView = new TopView(context);
    topView.setBackgroundColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
    frameLayout.addView(topView);
    avatarContainer = new FrameLayout(context);
    avatarContainer2 = new FrameLayout(context) {

        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            if (transitionOnlineText != null) {
                canvas.save();
                canvas.translate(onlineTextView[0].getX(), onlineTextView[0].getY());
                canvas.saveLayerAlpha(0, 0, transitionOnlineText.getMeasuredWidth(), transitionOnlineText.getMeasuredHeight(), (int) (255 * (1f - animationProgress)), Canvas.ALL_SAVE_FLAG);
                transitionOnlineText.draw(canvas);
                canvas.restore();
                canvas.restore();
                invalidate();
            }
        }
    };
    AndroidUtilities.updateViewVisibilityAnimated(avatarContainer2, true, 1f, false);
    frameLayout.addView(avatarContainer2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START, 0, 0, 0, 0));
    avatarContainer.setPivotX(0);
    avatarContainer.setPivotY(0);
    avatarContainer2.addView(avatarContainer, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0));
    avatarImage = new AvatarImageView(context) {

        @Override
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(info);
            if (getImageReceiver().hasNotThumb()) {
                info.setText(LocaleController.getString("AccDescrProfilePicture", R.string.AccDescrProfilePicture));
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, LocaleController.getString("Open", R.string.Open)));
                    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, LocaleController.getString("AccDescrOpenInPhotoViewer", R.string.AccDescrOpenInPhotoViewer)));
                }
            } else {
                info.setVisibleToUser(false);
            }
        }
    };
    avatarImage.getImageReceiver().setAllowDecodeSingleFrame(true);
    avatarImage.setRoundRadius(AndroidUtilities.dp(21));
    avatarImage.setPivotX(0);
    avatarImage.setPivotY(0);
    avatarContainer.addView(avatarImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    avatarImage.setOnClickListener(v -> {
        if (avatarBig != null) {
            return;
        }
        if (!AndroidUtilities.isTablet() && !isInLandscapeMode && avatarImage.getImageReceiver().hasNotThumb()) {
            openingAvatar = true;
            allowPullingDown = true;
            View child = null;
            for (int i = 0; i < listView.getChildCount(); i++) {
                if (listView.getChildAdapterPosition(listView.getChildAt(i)) == 0) {
                    child = listView.getChildAt(i);
                    break;
                }
            }
            if (child != null) {
                RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
                if (holder != null) {
                    Integer offset = positionToOffset.get(holder.getAdapterPosition());
                    if (offset != null) {
                        listView.smoothScrollBy(0, -(offset + (listView.getPaddingTop() - child.getTop() - actionBar.getMeasuredHeight())), CubicBezierInterpolator.EASE_OUT_QUINT);
                        return;
                    }
                }
            }
        }
        openAvatar();
    });
    avatarImage.setOnLongClickListener(v -> {
        if (avatarBig != null) {
            return false;
        }
        openAvatar();
        return false;
    });
    avatarProgressView = new RadialProgressView(context) {

        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        {
            paint.setColor(0x55000000);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            if (avatarImage != null && avatarImage.getImageReceiver().hasNotThumb()) {
                paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha()));
                canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
            }
            super.onDraw(canvas);
        }
    };
    avatarProgressView.setSize(AndroidUtilities.dp(26));
    avatarProgressView.setProgressColor(0xffffffff);
    avatarProgressView.setNoProgress(false);
    avatarContainer.addView(avatarProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    timeItem = new ImageView(context);
    timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
    timeItem.setScaleType(ImageView.ScaleType.CENTER);
    timeItem.setAlpha(0.0f);
    timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context));
    frameLayout.addView(timeItem, LayoutHelper.createFrame(34, 34, Gravity.TOP | Gravity.LEFT));
    updateTimeItem();
    showAvatarProgress(false, false);
    if (avatarsViewPager != null) {
        avatarsViewPager.onDestroy();
    }
    overlaysView = new OverlaysView(context);
    avatarsViewPager = new ProfileGalleryView(context, userId != 0 ? userId : -chatId, actionBar, listView, avatarImage, getClassGuid(), overlaysView);
    avatarsViewPager.setChatInfo(chatInfo);
    avatarContainer2.addView(avatarsViewPager);
    avatarContainer2.addView(overlaysView);
    avatarImage.setAvatarsViewPager(avatarsViewPager);
    avatarsViewPagerIndicatorView = new PagerIndicatorView(context);
    avatarContainer2.addView(avatarsViewPagerIndicatorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    frameLayout.addView(actionBar);
    for (int a = 0; a < nameTextView.length; a++) {
        if (playProfileAnimation == 0 && a == 0) {
            continue;
        }
        nameTextView[a] = new SimpleTextView(context);
        if (a == 1) {
            nameTextView[a].setTextColor(Theme.getColor(Theme.key_profile_title));
        } else {
            nameTextView[a].setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
        }
        nameTextView[a].setTextSize(18);
        nameTextView[a].setGravity(Gravity.LEFT);
        nameTextView[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        nameTextView[a].setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
        nameTextView[a].setPivotX(0);
        nameTextView[a].setPivotY(0);
        nameTextView[a].setAlpha(a == 0 ? 0.0f : 1.0f);
        if (a == 1) {
            nameTextView[a].setScrollNonFitText(true);
            nameTextView[a].setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        }
        int rightMargin = a == 0 ? (48 + ((callItemVisible && userId != 0) ? 48 : 0)) : 0;
        avatarContainer2.addView(nameTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, rightMargin, 0));
    }
    for (int a = 0; a < onlineTextView.length; a++) {
        onlineTextView[a] = new SimpleTextView(context);
        onlineTextView[a].setTextColor(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue));
        onlineTextView[a].setTextSize(14);
        onlineTextView[a].setGravity(Gravity.LEFT);
        onlineTextView[a].setAlpha(a == 0 || a == 2 ? 0.0f : 1.0f);
        if (a > 0) {
            onlineTextView[a].setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        }
        avatarContainer2.addView(onlineTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, a == 0 ? 48 : 8, 0));
    }
    mediaCounterTextView = new AudioPlayerAlert.ClippingTextViewSwitcher(context) {

        @Override
        protected TextView createTextView() {
            TextView textView = new TextView(context);
            textView.setTextColor(Theme.getColor(Theme.key_player_actionBarSubtitle));
            textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            textView.setSingleLine(true);
            textView.setEllipsize(TextUtils.TruncateAt.END);
            textView.setGravity(Gravity.LEFT);
            return textView;
        }
    };
    mediaCounterTextView.setAlpha(0.0f);
    avatarContainer2.addView(mediaCounterTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 8, 0));
    updateProfileData();
    writeButton = new RLottieImageView(context);
    Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY));
    CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)), 0, 0);
    combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
    writeButton.setBackground(combinedDrawable);
    if (userId != 0) {
        if (imageUpdater != null) {
            cameraDrawable = new RLottieDrawable(R.raw.camera_outline, "" + R.raw.camera_outline, AndroidUtilities.dp(56), AndroidUtilities.dp(56), false, null);
            writeButton.setAnimation(cameraDrawable);
            writeButton.setContentDescription(LocaleController.getString("AccDescrChangeProfilePicture", R.string.AccDescrChangeProfilePicture));
            writeButton.setPadding(AndroidUtilities.dp(2), 0, 0, AndroidUtilities.dp(2));
        } else {
            writeButton.setImageResource(R.drawable.profile_newmsg);
            writeButton.setContentDescription(LocaleController.getString("AccDescrOpenChat", R.string.AccDescrOpenChat));
        }
    } else {
        writeButton.setImageResource(R.drawable.profile_discuss);
        writeButton.setContentDescription(LocaleController.getString("ViewDiscussion", R.string.ViewDiscussion));
    }
    writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_actionIcon), PorterDuff.Mode.MULTIPLY));
    writeButton.setScaleType(ImageView.ScaleType.CENTER);
    frameLayout.addView(writeButton, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0));
    writeButton.setOnClickListener(v -> {
        if (writeButton.getTag() != null) {
            return;
        }
        onWriteButtonClick();
    });
    needLayout(false);
    if (scrollTo != -1) {
        if (writeButtonTag != null) {
            writeButton.setTag(0);
            writeButton.setScaleX(0.2f);
            writeButton.setScaleY(0.2f);
            writeButton.setAlpha(0.0f);
        }
    }
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
            if (openingAvatar && newState != RecyclerView.SCROLL_STATE_SETTLING) {
                openingAvatar = false;
            }
            if (searchItem != null) {
                scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
                searchItem.setEnabled(!scrolling && !isPulledDown);
            }
            sharedMediaLayout.scrollingByUser = listView.scrollingByUser;
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (fwdRestrictedHint != null) {
                fwdRestrictedHint.hide();
            }
            checkListViewScroll();
            if (participantsMap != null && !usersEndReached && layoutManager.findLastVisibleItemPosition() > membersEndRow - 8) {
                getChannelParticipants(false);
            }
            sharedMediaLayout.setPinnedToTop(sharedMediaLayout.getY() == 0);
        }
    });
    undoView = new UndoView(context);
    frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    expandAnimator = ValueAnimator.ofFloat(0f, 1f);
    expandAnimator.addUpdateListener(anim -> {
        final int newTop = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
        final float value = AndroidUtilities.lerp(expandAnimatorValues, currentExpanAnimatorFracture = anim.getAnimatedFraction());
        avatarContainer.setScaleX(avatarScale);
        avatarContainer.setScaleY(avatarScale);
        avatarContainer.setTranslationX(AndroidUtilities.lerp(avatarX, 0f, value));
        avatarContainer.setTranslationY(AndroidUtilities.lerp((float) Math.ceil(avatarY), 0f, value));
        avatarImage.setRoundRadius((int) AndroidUtilities.lerp(AndroidUtilities.dpf2(21f), 0f, value));
        if (searchItem != null) {
            searchItem.setAlpha(1.0f - value);
            searchItem.setScaleY(1.0f - value);
            searchItem.setVisibility(View.VISIBLE);
            searchItem.setClickable(searchItem.getAlpha() > .5f);
            if (qrItem != null) {
                float translation = AndroidUtilities.dp(48) * value;
                // if (searchItem.getVisibility() == View.VISIBLE)
                // translation += AndroidUtilities.dp(48);
                qrItem.setTranslationX(translation);
                avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
            }
        }
        if (extraHeight > AndroidUtilities.dp(88f) && expandProgress < 0.33f) {
            refreshNameAndOnlineXY();
        }
        if (scamDrawable != null) {
            scamDrawable.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue), Color.argb(179, 255, 255, 255), value));
        }
        if (lockIconDrawable != null) {
            lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, value), PorterDuff.Mode.MULTIPLY);
        }
        if (verifiedCrossfadeDrawable != null) {
            verifiedCrossfadeDrawable.setProgress(value);
        }
        final float k = AndroidUtilities.dpf2(8f);
        final float nameTextViewXEnd = AndroidUtilities.dpf2(16f) - nameTextView[1].getLeft();
        final float nameTextViewYEnd = newTop + extraHeight - AndroidUtilities.dpf2(38f) - nameTextView[1].getBottom();
        final float nameTextViewCx = k + nameX + (nameTextViewXEnd - nameX) / 2f;
        final float nameTextViewCy = k + nameY + (nameTextViewYEnd - nameY) / 2f;
        final float nameTextViewX = (1 - value) * (1 - value) * nameX + 2 * (1 - value) * value * nameTextViewCx + value * value * nameTextViewXEnd;
        final float nameTextViewY = (1 - value) * (1 - value) * nameY + 2 * (1 - value) * value * nameTextViewCy + value * value * nameTextViewYEnd;
        final float onlineTextViewXEnd = AndroidUtilities.dpf2(16f) - onlineTextView[1].getLeft();
        final float onlineTextViewYEnd = newTop + extraHeight - AndroidUtilities.dpf2(18f) - onlineTextView[1].getBottom();
        final float onlineTextViewCx = k + onlineX + (onlineTextViewXEnd - onlineX) / 2f;
        final float onlineTextViewCy = k + onlineY + (onlineTextViewYEnd - onlineY) / 2f;
        final float onlineTextViewX = (1 - value) * (1 - value) * onlineX + 2 * (1 - value) * value * onlineTextViewCx + value * value * onlineTextViewXEnd;
        final float onlineTextViewY = (1 - value) * (1 - value) * onlineY + 2 * (1 - value) * value * onlineTextViewCy + value * value * onlineTextViewYEnd;
        nameTextView[1].setTranslationX(nameTextViewX);
        nameTextView[1].setTranslationY(nameTextViewY);
        onlineTextView[1].setTranslationX(onlineTextViewX);
        onlineTextView[1].setTranslationY(onlineTextViewY);
        mediaCounterTextView.setTranslationX(onlineTextViewX);
        mediaCounterTextView.setTranslationY(onlineTextViewY);
        final Object onlineTextViewTag = onlineTextView[1].getTag();
        int statusColor;
        if (onlineTextViewTag instanceof String) {
            statusColor = Theme.getColor((String) onlineTextViewTag);
        } else {
            statusColor = Theme.getColor(Theme.key_avatar_subtitleInProfileBlue);
        }
        onlineTextView[1].setTextColor(ColorUtils.blendARGB(statusColor, Color.argb(179, 255, 255, 255), value));
        if (extraHeight > AndroidUtilities.dp(88f)) {
            nameTextView[1].setPivotY(AndroidUtilities.lerp(0, nameTextView[1].getMeasuredHeight(), value));
            nameTextView[1].setScaleX(AndroidUtilities.lerp(1.12f, 1.67f, value));
            nameTextView[1].setScaleY(AndroidUtilities.lerp(1.12f, 1.67f, value));
        }
        needLayoutText(Math.min(1f, extraHeight / AndroidUtilities.dp(88f)));
        nameTextView[1].setTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_profile_title), Color.WHITE, value));
        actionBar.setItemsColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_actionBarDefaultIcon), Color.WHITE, value), false);
        avatarImage.setForegroundAlpha(value);
        final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
        params.width = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(42f), listView.getMeasuredWidth() / avatarScale, value);
        params.height = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(42f), (extraHeight + newTop) / avatarScale, value);
        params.leftMargin = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(64f), 0f, value);
        avatarContainer.requestLayout();
    });
    expandAnimator.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
    expandAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            actionBar.setItemsBackgroundColor(isPulledDown ? Theme.ACTION_BAR_WHITE_SELECTOR_COLOR : Theme.getColor(Theme.key_avatar_actionBarSelectorBlue), false);
            avatarImage.clearForeground();
            doNotSetForeground = false;
        }
    });
    updateRowsIds();
    updateSelectedMediaTabText();
    fwdRestrictedHint = new HintView(getParentActivity(), 9);
    fwdRestrictedHint.setAlpha(0);
    frameLayout.addView(fwdRestrictedHint, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 12, 0, 12, 0));
    sharedMediaLayout.setForwardRestrictedHint(fwdRestrictedHint);
    ViewGroup decorView;
    if (Build.VERSION.SDK_INT >= 21) {
        decorView = (ViewGroup) getParentActivity().getWindow().getDecorView();
    } else {
        decorView = frameLayout;
    }
    pinchToZoomHelper = new PinchToZoomHelper(decorView, frameLayout) {

        Paint statusBarPaint;

        @Override
        protected void invalidateViews() {
            super.invalidateViews();
            fragmentView.invalidate();
            for (int i = 0; i < avatarsViewPager.getChildCount(); i++) {
                avatarsViewPager.getChildAt(i).invalidate();
            }
            if (writeButton != null) {
                writeButton.invalidate();
            }
        }

        @Override
        protected void drawOverlays(Canvas canvas, float alpha, float parentOffsetX, float parentOffsetY, float clipTop, float clipBottom) {
            if (alpha > 0) {
                AndroidUtilities.rectTmp.set(0, 0, avatarsViewPager.getMeasuredWidth(), avatarsViewPager.getMeasuredHeight() + AndroidUtilities.dp(30));
                canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (255 * alpha), Canvas.ALL_SAVE_FLAG);
                avatarContainer2.draw(canvas);
                if (actionBar.getOccupyStatusBar()) {
                    if (statusBarPaint == null) {
                        statusBarPaint = new Paint();
                        statusBarPaint.setColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (255 * 0.2f)));
                    }
                    canvas.drawRect(actionBar.getX(), actionBar.getY(), actionBar.getX() + actionBar.getMeasuredWidth(), actionBar.getY() + AndroidUtilities.statusBarHeight, statusBarPaint);
                }
                canvas.save();
                canvas.translate(actionBar.getX(), actionBar.getY());
                actionBar.draw(canvas);
                canvas.restore();
                if (writeButton != null && writeButton.getVisibility() == View.VISIBLE && writeButton.getAlpha() > 0) {
                    canvas.save();
                    float s = 0.5f + 0.5f * alpha;
                    canvas.scale(s, s, writeButton.getX() + writeButton.getMeasuredWidth() / 2f, writeButton.getY() + writeButton.getMeasuredHeight() / 2f);
                    canvas.translate(writeButton.getX(), writeButton.getY());
                    writeButton.draw(canvas);
                    canvas.restore();
                }
                canvas.restore();
            }
        }

        @Override
        protected boolean zoomEnabled(View child, ImageReceiver receiver) {
            if (!super.zoomEnabled(child, receiver)) {
                return false;
            }
            return listView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING;
        }
    };
    pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {

        @Override
        public void onZoomStarted(MessageObject messageObject) {
            listView.cancelClickRunnables(true);
            if (sharedMediaLayout != null && sharedMediaLayout.getCurrentListView() != null) {
                sharedMediaLayout.getCurrentListView().cancelClickRunnables(true);
            }
            Bitmap bitmap = pinchToZoomHelper.getPhotoImage() == null ? null : pinchToZoomHelper.getPhotoImage().getBitmap();
            if (bitmap != null) {
                topView.setBackgroundColor(ColorUtils.blendARGB(AndroidUtilities.calcBitmapColor(bitmap), Theme.getColor(Theme.key_windowBackgroundWhite), 0.1f));
            }
        }
    });
    avatarsViewPager.setPinchToZoomHelper(pinchToZoomHelper);
    scrimPaint.setAlpha(0);
    actionBarBackgroundPaint.setColor(Theme.getColor(Theme.key_listSelector));
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Bundle(android.os.Bundle) BufferedInputStream(java.io.BufferedInputStream) SettingsSuggestionCell(org.telegram.ui.Cells.SettingsSuggestionCell) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Property(android.util.Property) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) RadialProgressView(org.telegram.ui.Components.RadialProgressView) Manifest(android.Manifest) Keep(androidx.annotation.Keep) ChatThemeController(org.telegram.messenger.ChatThemeController) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) Display(android.view.Display) Canvas(android.graphics.Canvas) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ContextCompat(androidx.core.content.ContextCompat) NotificationsController(org.telegram.messenger.NotificationsController) ViewCompat(androidx.core.view.ViewCompat) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BackButtonMenu(org.telegram.ui.Components.BackButtonMenu) UndoView(org.telegram.ui.Components.UndoView) AnimationProperties(org.telegram.ui.Components.AnimationProperties) Set(java.util.Set) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) HapticFeedbackConstants(android.view.HapticFeedbackConstants) CountDownLatch(java.util.concurrent.CountDownLatch) TextPaint(android.text.TextPaint) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerCell(org.telegram.ui.Cells.DividerCell) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FileLoader(org.telegram.messenger.FileLoader) ZipOutputStream(java.util.zip.ZipOutputStream) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) SystemClock(android.os.SystemClock) TimerDrawable(org.telegram.ui.Components.TimerDrawable) SettingsSearchCell(org.telegram.ui.Cells.SettingsSearchCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) SharedMediaLayout(org.telegram.ui.Components.SharedMediaLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) TLRPC(org.telegram.tgnet.TLRPC) GradientDrawable(android.graphics.drawable.GradientDrawable) Toast(android.widget.Toast) PhoneFormat(org.telegram.PhoneFormat.PhoneFormat) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) BuildConfig(org.telegram.messenger.BuildConfig) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) LinkedHashSet(java.util.LinkedHashSet) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) FileOutputStream(java.io.FileOutputStream) TextUtils(android.text.TextUtils) AboutLinkCell(org.telegram.ui.Cells.AboutLinkCell) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) GraySectionCell(org.telegram.ui.Cells.GraySectionCell) Configuration(android.content.res.Configuration) ColorUtils(androidx.core.graphics.ColorUtils) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) ImageUpdater(org.telegram.ui.Components.ImageUpdater) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) Animator(android.animation.Animator) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) TextCell(org.telegram.ui.Cells.TextCell) Locale(java.util.Locale) MediaController(org.telegram.messenger.MediaController) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) DataSetObserver(android.database.DataSetObserver) ZipEntry(java.util.zip.ZipEntry) RectF(android.graphics.RectF) ImageLoader(org.telegram.messenger.ImageLoader) Utilities(org.telegram.messenger.Utilities) DiffUtil(androidx.recyclerview.widget.DiffUtil) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ViewGroup(android.view.ViewGroup) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) ScamDrawable(org.telegram.ui.Components.ScamDrawable) FileProvider(androidx.core.content.FileProvider) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Typeface(android.graphics.Typeface) NestedScrollingParentHelper(androidx.core.view.NestedScrollingParentHelper) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Spanned(android.text.Spanned) SparseIntArray(android.util.SparseIntArray) Theme(org.telegram.ui.ActionBar.Theme) TextDetailCell(org.telegram.ui.Cells.TextDetailCell) PagerAdapter(androidx.viewpager.widget.PagerAdapter) BulletinFactory(org.telegram.ui.Components.BulletinFactory) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) HeaderCell(org.telegram.ui.Cells.HeaderCell) PackageInfo(android.content.pm.PackageInfo) HashSet(java.util.HashSet) VelocityTracker(android.view.VelocityTracker) MotionEvent(android.view.MotionEvent) NestedScrollingParent3(androidx.core.view.NestedScrollingParent3) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLObject(org.telegram.tgnet.TLObject) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) MediaDataController(org.telegram.messenger.MediaDataController) Build(android.os.Build) SerializedData(org.telegram.tgnet.SerializedData) DialogInterface(android.content.DialogInterface) Browser(org.telegram.messenger.browser.Browser) ChatAvatarContainer(org.telegram.ui.Components.ChatAvatarContainer) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileInputStream(java.io.FileInputStream) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) ViewTreeObserver(android.view.ViewTreeObserver) Comparator(java.util.Comparator) ImageReceiver(org.telegram.messenger.ImageReceiver) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ArrayList(java.util.ArrayList) AboutLinkCell(org.telegram.ui.Cells.AboutLinkCell) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) EditText(android.widget.EditText) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TimerDrawable(org.telegram.ui.Components.TimerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) UserConfig(org.telegram.messenger.UserConfig) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) UserObject(org.telegram.messenger.UserObject) ChatObject(org.telegram.messenger.ChatObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) AnimatorSet(android.animation.AnimatorSet) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) MessagesController(org.telegram.messenger.MessagesController) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageLocation(org.telegram.messenger.ImageLocation) UndoView(org.telegram.ui.Components.UndoView) VelocityTracker(android.view.VelocityTracker) SharedPreferences(android.content.SharedPreferences) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Intent(android.content.Intent) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) RecyclerView(androidx.recyclerview.widget.RecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ValueAnimator(android.animation.ValueAnimator) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ImageReceiver(org.telegram.messenger.ImageReceiver) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) RadialProgressView(org.telegram.ui.Components.RadialProgressView) TimerDrawable(org.telegram.ui.Components.TimerDrawable) Canvas(android.graphics.Canvas) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) File(java.io.File) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) SharedMediaLayout(org.telegram.ui.Components.SharedMediaLayout) RLottieImageView(org.telegram.ui.Components.RLottieImageView) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) Bitmap(android.graphics.Bitmap) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) HintView(org.telegram.ui.Components.HintView) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) FrameLayout(android.widget.FrameLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) MessageObject(org.telegram.messenger.MessageObject)

Aggregations

HintView (org.telegram.ui.Components.HintView)17 Paint (android.graphics.Paint)11 SuppressLint (android.annotation.SuppressLint)10 TextPaint (android.text.TextPaint)9 ChecksHintView (org.telegram.ui.Components.ChecksHintView)9 View (android.view.View)8 TextView (android.widget.TextView)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 RecyclerListView (org.telegram.ui.Components.RecyclerListView)7 SizeNotifierFrameLayout (org.telegram.ui.Components.SizeNotifierFrameLayout)7 TextSelectionHint (org.telegram.ui.Components.TextSelectionHint)7 SharedPreferences (android.content.SharedPreferences)6 ImageView (android.widget.ImageView)6 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)6 Canvas (android.graphics.Canvas)5 MessageObject (org.telegram.messenger.MessageObject)5 BackupImageView (org.telegram.ui.Components.BackupImageView)5 UndoView (org.telegram.ui.Components.UndoView)5 Animator (android.animation.Animator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)4