Search in sources :

Example 1 with ViewStubCompat

use of androidx.appcompat.widget.ViewStubCompat in project GreenHouse by utsanjan.

the class AppCompatDelegateImpl method startSupportActionModeFromWindow.

ActionMode startSupportActionModeFromWindow(ActionMode.Callback callback) {
    AppCompatCallback appCompatCallback;
    Context actionBarContext;
    endOnGoingFadeAnimation();
    ActionMode actionMode = this.mActionMode;
    if (actionMode != null) {
        actionMode.finish();
    }
    if (!(callback instanceof ActionModeCallbackWrapperV9)) {
        callback = new ActionModeCallbackWrapperV9(callback);
    }
    ActionMode mode = null;
    AppCompatCallback appCompatCallback2 = this.mAppCompatCallback;
    if (appCompatCallback2 != null && !this.mIsDestroyed) {
        try {
            mode = appCompatCallback2.onWindowStartingSupportActionMode(callback);
        } catch (AbstractMethodError e) {
        }
    }
    if (mode != null) {
        this.mActionMode = mode;
    } else {
        boolean z = true;
        if (this.mActionModeView == null) {
            if (this.mIsFloating) {
                TypedValue outValue = new TypedValue();
                Resources.Theme baseTheme = this.mContext.getTheme();
                baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
                if (outValue.resourceId != 0) {
                    Resources.Theme actionBarTheme = this.mContext.getResources().newTheme();
                    actionBarTheme.setTo(baseTheme);
                    actionBarTheme.applyStyle(outValue.resourceId, true);
                    actionBarContext = new ContextThemeWrapper(this.mContext, 0);
                    actionBarContext.getTheme().setTo(actionBarTheme);
                } else {
                    actionBarContext = this.mContext;
                }
                this.mActionModeView = new ActionBarContextView(actionBarContext);
                PopupWindow popupWindow = new PopupWindow(actionBarContext, (AttributeSet) null, R.attr.actionModePopupWindowStyle);
                this.mActionModePopup = popupWindow;
                PopupWindowCompat.setWindowLayoutType(popupWindow, 2);
                this.mActionModePopup.setContentView(this.mActionModeView);
                this.mActionModePopup.setWidth(-1);
                actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
                int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
                this.mActionModeView.setContentHeight(height);
                this.mActionModePopup.setHeight(-2);
                this.mShowActionModePopup = new // from class: androidx.appcompat.app.AppCompatDelegateImpl.6
                Runnable() {

                    // java.lang.Runnable
                    @Override
                    public void run() {
                        AppCompatDelegateImpl.this.mActionModePopup.showAtLocation(AppCompatDelegateImpl.this.mActionModeView, 55, 0, 0);
                        AppCompatDelegateImpl.this.endOnGoingFadeAnimation();
                        if (AppCompatDelegateImpl.this.shouldAnimateActionModeView()) {
                            AppCompatDelegateImpl.this.mActionModeView.setAlpha(0.0f);
                            AppCompatDelegateImpl appCompatDelegateImpl = AppCompatDelegateImpl.this;
                            appCompatDelegateImpl.mFadeAnim = ViewCompat.animate(appCompatDelegateImpl.mActionModeView).alpha(1.0f);
                            AppCompatDelegateImpl.this.mFadeAnim.setListener(new // from class: androidx.appcompat.app.AppCompatDelegateImpl.6.1
                            ViewPropertyAnimatorListenerAdapter() {

                                // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
                                @Override
                                public void onAnimationStart(View view) {
                                    AppCompatDelegateImpl.this.mActionModeView.setVisibility(0);
                                }

                                // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
                                @Override
                                public void onAnimationEnd(View view) {
                                    AppCompatDelegateImpl.this.mActionModeView.setAlpha(1.0f);
                                    AppCompatDelegateImpl.this.mFadeAnim.setListener(null);
                                    AppCompatDelegateImpl.this.mFadeAnim = null;
                                }
                            });
                            return;
                        }
                        AppCompatDelegateImpl.this.mActionModeView.setAlpha(1.0f);
                        AppCompatDelegateImpl.this.mActionModeView.setVisibility(0);
                    }
                };
            } else {
                ViewStubCompat stub = (ViewStubCompat) this.mSubDecor.findViewById(R.id.action_mode_bar_stub);
                if (stub != null) {
                    stub.setLayoutInflater(LayoutInflater.from(getActionBarThemedContext()));
                    this.mActionModeView = (ActionBarContextView) stub.inflate();
                }
            }
        }
        if (this.mActionModeView != null) {
            endOnGoingFadeAnimation();
            this.mActionModeView.killMode();
            Context context = this.mActionModeView.getContext();
            ActionBarContextView actionBarContextView = this.mActionModeView;
            if (this.mActionModePopup != null) {
                z = false;
            }
            ActionMode mode2 = new StandaloneActionMode(context, actionBarContextView, callback, z);
            if (callback.onCreateActionMode(mode2, mode2.getMenu())) {
                mode2.invalidate();
                this.mActionModeView.initForMode(mode2);
                this.mActionMode = mode2;
                if (shouldAnimateActionModeView()) {
                    this.mActionModeView.setAlpha(0.0f);
                    ViewPropertyAnimatorCompat alpha = ViewCompat.animate(this.mActionModeView).alpha(1.0f);
                    this.mFadeAnim = alpha;
                    alpha.setListener(new // from class: androidx.appcompat.app.AppCompatDelegateImpl.7
                    ViewPropertyAnimatorListenerAdapter() {

                        // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
                        @Override
                        public void onAnimationStart(View view) {
                            AppCompatDelegateImpl.this.mActionModeView.setVisibility(0);
                            AppCompatDelegateImpl.this.mActionModeView.sendAccessibilityEvent(32);
                            if (AppCompatDelegateImpl.this.mActionModeView.getParent() instanceof View) {
                                ViewCompat.requestApplyInsets((View) AppCompatDelegateImpl.this.mActionModeView.getParent());
                            }
                        }

                        // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener
                        @Override
                        public void onAnimationEnd(View view) {
                            AppCompatDelegateImpl.this.mActionModeView.setAlpha(1.0f);
                            AppCompatDelegateImpl.this.mFadeAnim.setListener(null);
                            AppCompatDelegateImpl.this.mFadeAnim = null;
                        }
                    });
                } else {
                    this.mActionModeView.setAlpha(1.0f);
                    this.mActionModeView.setVisibility(0);
                    this.mActionModeView.sendAccessibilityEvent(32);
                    if (this.mActionModeView.getParent() instanceof View) {
                        ViewCompat.requestApplyInsets((View) this.mActionModeView.getParent());
                    }
                }
                if (this.mActionModePopup != null) {
                    this.mWindow.getDecorView().post(this.mShowActionModePopup);
                }
            } else {
                this.mActionMode = null;
            }
        }
    }
    ActionMode actionMode2 = this.mActionMode;
    if (!(actionMode2 == null || (appCompatCallback = this.mAppCompatCallback) == null)) {
        appCompatCallback.onSupportActionModeStarted(actionMode2);
    }
    return this.mActionMode;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) View(android.view.View) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) TextView(android.widget.TextView) MenuView(androidx.appcompat.view.menu.MenuView) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) ActionMode(android.view.ActionMode) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ActionMode(androidx.appcompat.view.ActionMode) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) ViewPropertyAnimatorCompat(androidx.core.view.ViewPropertyAnimatorCompat) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) VectorEnabledTintResources(androidx.appcompat.widget.VectorEnabledTintResources) Resources(android.content.res.Resources) ViewPropertyAnimatorListenerAdapter(androidx.core.view.ViewPropertyAnimatorListenerAdapter) TypedValue(android.util.TypedValue)

Example 2 with ViewStubCompat

use of androidx.appcompat.widget.ViewStubCompat in project sesl-appcompat by OneUIProject.

the class AppCompatDelegateImpl method startSupportActionModeFromWindow.

ActionMode startSupportActionModeFromWindow(@NonNull ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    if (mActionMode != null) {
        mActionMode.finish();
    }
    if (!(callback instanceof ActionModeCallbackWrapperV9)) {
        // If the callback hasn't been wrapped yet, wrap it
        callback = new ActionModeCallbackWrapperV9(callback);
    }
    ActionMode mode = null;
    if (mAppCompatCallback != null && !mDestroyed) {
        try {
            mode = mAppCompatCallback.onWindowStartingSupportActionMode(callback);
        } catch (AbstractMethodError ame) {
        // Older apps might not implement this callback method.
        }
    }
    if (mode != null) {
        mActionMode = mode;
    } else {
        if (mActionModeView == null) {
            if (mIsFloating) {
                // Use the action bar theme.
                final TypedValue outValue = new TypedValue();
                final Resources.Theme baseTheme = mContext.getTheme();
                baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
                final Context actionBarContext;
                if (outValue.resourceId != 0) {
                    final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                    actionBarTheme.setTo(baseTheme);
                    actionBarTheme.applyStyle(outValue.resourceId, true);
                    actionBarContext = new ContextThemeWrapper(mContext, 0);
                    actionBarContext.getTheme().setTo(actionBarTheme);
                } else {
                    actionBarContext = mContext;
                }
                mActionModeView = new ActionBarContextView(actionBarContext);
                mActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
                PopupWindowCompat.setWindowLayoutType(mActionModePopup, WindowManager.LayoutParams.TYPE_APPLICATION);
                mActionModePopup.setContentView(mActionModeView);
                mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
                actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
                final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
                mActionModeView.setContentHeight(height);
                mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
                mShowActionModePopup = new Runnable() {

                    @Override
                    public void run() {
                        mActionModePopup.showAtLocation(mActionModeView, Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                        endOnGoingFadeAnimation();
                        if (shouldAnimateActionModeView()) {
                            mActionModeView.setAlpha(0f);
                            mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                            mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {

                                @Override
                                public void onAnimationStart(View view) {
                                    mActionModeView.setVisibility(VISIBLE);
                                }

                                @Override
                                public void onAnimationEnd(View view) {
                                    mActionModeView.setAlpha(1f);
                                    mFadeAnim.setListener(null);
                                    mFadeAnim = null;
                                }
                            });
                        } else {
                            mActionModeView.setAlpha(1f);
                            mActionModeView.setVisibility(VISIBLE);
                        }
                    }
                };
            } else {
                Context context = mSubDecor.getContext();
                View actionModeContainer = mSubDecor.findViewById(context.getResources().getIdentifier("collapsing_toolbar", "id", context.getPackageName()));
                if (actionModeContainer == null) {
                    actionModeContainer = mSubDecor.findViewById(context.getResources().getIdentifier("sesl_toolbar_container", "id", context.getPackageName()));
                }
                ViewStubCompat stub;
                if (actionModeContainer != null) {
                    if (mOverlayActionMode) {
                        stub = mSubDecor.findViewById(R.id.action_mode_bar_stub);
                    } else {
                        stub = actionModeContainer.findViewById(R.id.action_mode_bar_stub);
                    }
                } else {
                    stub = mSubDecor.findViewById(R.id.action_mode_bar_stub);
                }
                if (stub != null) {
                    // Set the layout inflater so that it is inflated with the action bar's context
                    stub.setLayoutInflater(LayoutInflater.from(getActionBarThemedContext()));
                    mActionModeView = (ActionBarContextView) stub.inflate();
                }
            }
        }
        if (mActionModeView != null) {
            endOnGoingFadeAnimation();
            mActionModeView.killMode();
            mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, callback, mActionModePopup == null);
            if (callback.onCreateActionMode(mode, mode.getMenu())) {
                mode.invalidate();
                mActionModeView.initForMode(mode);
                mActionMode = mode;
                if (shouldAnimateActionModeView()) {
                    mActionModeView.setAlpha(0f);
                    mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                    mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {

                        @Override
                        public void onAnimationStart(View view) {
                            mActionModeView.setVisibility(VISIBLE);
                            mActionModeView.sendAccessibilityEvent(AccessibilityEventCompat.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED);
                            if (mActionModeView.getParent() instanceof View) {
                                ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                            }
                        }

                        @Override
                        public void onAnimationEnd(View view) {
                            mActionModeView.setAlpha(1f);
                            mFadeAnim.setListener(null);
                            mFadeAnim = null;
                        }
                    });
                } else {
                    mActionModeView.setAlpha(1f);
                    mActionModeView.setVisibility(VISIBLE);
                    mActionModeView.sendAccessibilityEvent(AccessibilityEventCompat.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED);
                    if (mActionModeView.getParent() instanceof View) {
                        ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                    }
                }
                if (mActionModePopup != null) {
                    mWindow.getDecorView().post(mShowActionModePopup);
                }
            } else {
                mActionMode = null;
            }
        }
    }
    if (mActionMode != null && mAppCompatCallback != null) {
        mAppCompatCallback.onSupportActionModeStarted(mActionMode);
    }
    return mActionMode;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) MenuView(androidx.appcompat.view.menu.MenuView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ActionMode(androidx.appcompat.view.ActionMode) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) VectorEnabledTintResources(androidx.appcompat.widget.VectorEnabledTintResources) Resources(android.content.res.Resources) ViewPropertyAnimatorListenerAdapter(androidx.core.view.ViewPropertyAnimatorListenerAdapter) TypedValue(android.util.TypedValue)

Example 3 with ViewStubCompat

use of androidx.appcompat.widget.ViewStubCompat in project sesl by OneUIProject.

the class AppCompatDelegateImpl method startSupportActionModeFromWindow.

ActionMode startSupportActionModeFromWindow(@NonNull ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    if (mActionMode != null) {
        mActionMode.finish();
    }
    if (!(callback instanceof ActionModeCallbackWrapperV9)) {
        // If the callback hasn't been wrapped yet, wrap it
        callback = new ActionModeCallbackWrapperV9(callback);
    }
    ActionMode mode = null;
    if (mAppCompatCallback != null && !mDestroyed) {
        try {
            mode = mAppCompatCallback.onWindowStartingSupportActionMode(callback);
        } catch (AbstractMethodError ame) {
        // Older apps might not implement this callback method.
        }
    }
    if (mode != null) {
        mActionMode = mode;
    } else {
        if (mActionModeView == null) {
            if (mIsFloating) {
                // Use the action bar theme.
                final TypedValue outValue = new TypedValue();
                final Resources.Theme baseTheme = mContext.getTheme();
                baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
                final Context actionBarContext;
                if (outValue.resourceId != 0) {
                    final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                    actionBarTheme.setTo(baseTheme);
                    actionBarTheme.applyStyle(outValue.resourceId, true);
                    actionBarContext = new ContextThemeWrapper(mContext, 0);
                    actionBarContext.getTheme().setTo(actionBarTheme);
                } else {
                    actionBarContext = mContext;
                }
                mActionModeView = new ActionBarContextView(actionBarContext);
                mActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
                PopupWindowCompat.setWindowLayoutType(mActionModePopup, WindowManager.LayoutParams.TYPE_APPLICATION);
                mActionModePopup.setContentView(mActionModeView);
                mActionModePopup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
                actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
                final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
                mActionModeView.setContentHeight(height);
                mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
                mShowActionModePopup = new Runnable() {

                    @Override
                    public void run() {
                        mActionModePopup.showAtLocation(mActionModeView, Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                        endOnGoingFadeAnimation();
                        if (shouldAnimateActionModeView()) {
                            mActionModeView.setAlpha(0f);
                            mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                            mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {

                                @Override
                                public void onAnimationStart(View view) {
                                    mActionModeView.setVisibility(VISIBLE);
                                }

                                @Override
                                public void onAnimationEnd(View view) {
                                    mActionModeView.setAlpha(1f);
                                    mFadeAnim.setListener(null);
                                    mFadeAnim = null;
                                }
                            });
                        } else {
                            mActionModeView.setAlpha(1f);
                            mActionModeView.setVisibility(VISIBLE);
                        }
                    }
                };
            } else {
                Context context = mSubDecor.getContext();
                View actionModeContainer = mSubDecor.findViewById(context.getResources().getIdentifier("collapsing_toolbar", "id", context.getPackageName()));
                if (actionModeContainer == null) {
                    actionModeContainer = mSubDecor.findViewById(context.getResources().getIdentifier("sesl_toolbar_container", "id", context.getPackageName()));
                }
                ViewStubCompat stub;
                if (actionModeContainer != null) {
                    if (mOverlayActionMode) {
                        stub = mSubDecor.findViewById(R.id.action_mode_bar_stub);
                    } else {
                        stub = actionModeContainer.findViewById(R.id.action_mode_bar_stub);
                    }
                } else {
                    stub = mSubDecor.findViewById(R.id.action_mode_bar_stub);
                }
                if (stub != null) {
                    // Set the layout inflater so that it is inflated with the action bar's context
                    stub.setLayoutInflater(LayoutInflater.from(getActionBarThemedContext()));
                    mActionModeView = (ActionBarContextView) stub.inflate();
                }
            }
        }
        if (mActionModeView != null) {
            endOnGoingFadeAnimation();
            mActionModeView.killMode();
            mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView, callback, mActionModePopup == null);
            if (callback.onCreateActionMode(mode, mode.getMenu())) {
                mode.invalidate();
                mActionModeView.initForMode(mode);
                mActionMode = mode;
                if (shouldAnimateActionModeView()) {
                    mActionModeView.setAlpha(0f);
                    mFadeAnim = ViewCompat.animate(mActionModeView).alpha(1f);
                    mFadeAnim.setListener(new ViewPropertyAnimatorListenerAdapter() {

                        @Override
                        public void onAnimationStart(View view) {
                            mActionModeView.setVisibility(VISIBLE);
                            mActionModeView.sendAccessibilityEvent(AccessibilityEventCompat.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED);
                            if (mActionModeView.getParent() instanceof View) {
                                ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                            }
                        }

                        @Override
                        public void onAnimationEnd(View view) {
                            mActionModeView.setAlpha(1f);
                            mFadeAnim.setListener(null);
                            mFadeAnim = null;
                        }
                    });
                } else {
                    mActionModeView.setAlpha(1f);
                    mActionModeView.setVisibility(VISIBLE);
                    mActionModeView.sendAccessibilityEvent(AccessibilityEventCompat.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED);
                    if (mActionModeView.getParent() instanceof View) {
                        ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                    }
                }
                if (mActionModePopup != null) {
                    mWindow.getDecorView().post(mShowActionModePopup);
                }
            } else {
                mActionMode = null;
            }
        }
    }
    if (mActionMode != null && mAppCompatCallback != null) {
        mAppCompatCallback.onSupportActionModeStarted(mActionMode);
    }
    return mActionMode;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) MenuView(androidx.appcompat.view.menu.MenuView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) StandaloneActionMode(androidx.appcompat.view.StandaloneActionMode) ActionMode(androidx.appcompat.view.ActionMode) ActionBarContextView(androidx.appcompat.widget.ActionBarContextView) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) VectorEnabledTintResources(androidx.appcompat.widget.VectorEnabledTintResources) Resources(android.content.res.Resources) ViewPropertyAnimatorListenerAdapter(androidx.core.view.ViewPropertyAnimatorListenerAdapter) TypedValue(android.util.TypedValue)

Example 4 with ViewStubCompat

use of androidx.appcompat.widget.ViewStubCompat in project iGap-Android by KianIranian-STDG.

the class FragmentChat method inflateReplayLayoutIntoStub.

@SuppressLint("RestrictedApi")
private void inflateReplayLayoutIntoStub(MessageObject messageObject, boolean isEdit) {
    // TODO: 12/28/20  refactor message
    if (rootView.findViewById(R.id.replayLayoutAboveEditText) == null) {
        ViewStubCompat stubView = rootView.findViewById(R.id.replayLayoutStub);
        stubView.setInflatedId(R.id.replayLayoutAboveEditText);
        stubView.setLayoutResource(R.layout.layout_chat_reply);
        stubView.inflate();
        inflateReplayLayoutIntoStub(messageObject, isEdit);
    } else {
        mReplayLayout = rootView.findViewById(R.id.replayLayoutAboveEditText);
        mReplayLayout.setVisibility(View.VISIBLE);
        TextView replayTo = mReplayLayout.findViewById(R.id.replayTo);
        replayTo.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
        TextView replayFrom = mReplayLayout.findViewById(R.id.replyFrom);
        replayFrom.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
        FontIconTextView replayIcon = rootView.findViewById(R.id.lcr_imv_replay);
        if (isEdit)
            replayIcon.setText(getString(R.string.icon_new_conversation));
        else
            replayIcon.setText(getString(R.string.icon_reply));
        ImageView thumbnail = mReplayLayout.findViewById(R.id.thumbnail);
        thumbnail.setImageResource(android.R.color.transparent);
        TextView closeReplay = mReplayLayout.findViewById(R.id.cancelIcon);
        closeReplay.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (isEdit)
                    removeEditedMessage();
                else
                    clearReplyView();
            }
        });
        thumbnail.setVisibility(View.VISIBLE);
        if (messageObject.isForwarded()) {
            AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.forwardedMessage.messageType, messageObject.forwardedMessage);
            String _text = AppUtils.conversionMessageType(messageObject.forwardedMessage.messageType);
            if (_text != null && _text.length() > 0) {
                ReplySetText(replayTo, _text);
            } else {
                ReplySetText(replayTo, messageObject.forwardedMessage.message);
            }
        } else {
            AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.messageType, messageObject);
            String _text = AppUtils.conversionMessageType(messageObject.messageType);
            if (_text != null && _text.length() > 0) {
                ReplySetText(replayTo, _text);
            } else {
                ReplySetText(replayTo, messageObject.message);
            }
        }
        if (!isEdit) {
            if (chatType == CHANNEL) {
                RealmRoom realmRoom = DbManager.getInstance().doRealmTask(realm -> {
                    return realm.where(RealmRoom.class).equalTo("id", messageObject.roomId).findFirst();
                });
                if (realmRoom != null) {
                    replayFrom.setText(EmojiManager.getInstance().replaceEmoji(realmRoom.getTitle(), replayFrom.getPaint().getFontMetricsInt()));
                }
            } else {
                RealmRegisteredInfo userInfo = DbManager.getInstance().doRealmTask(realm -> {
                    return RealmRegisteredInfo.getRegistrationInfo(realm, messageObject.userId);
                });
                if (userInfo != null) {
                    replayFrom.setText(EmojiManager.getInstance().replaceEmoji(userInfo.getDisplayName(), replayFrom.getPaint().getFontMetricsInt()));
                }
            }
        } else {
            replayFrom.setText(getString(R.string.edit));
        }
        // I set tag to retrieve it later when sending message
        mReplayLayout.setTag(messageObject);
    }
}
Also used : ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) FontIconTextView(net.iGap.module.FontIconTextView) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) RealmRoom(net.iGap.realm.RealmRoom) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) BadgeView(net.iGap.adapter.items.chat.BadgeView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) FontIconTextView(net.iGap.module.FontIconTextView) StructWebView(net.iGap.module.structs.StructWebView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) SuppressLint(android.annotation.SuppressLint)

Aggregations

View (android.view.View)4 TextView (android.widget.TextView)4 ViewStubCompat (androidx.appcompat.widget.ViewStubCompat)4 SuppressLint (android.annotation.SuppressLint)3 Context (android.content.Context)3 Resources (android.content.res.Resources)3 TypedValue (android.util.TypedValue)3 PopupWindow (android.widget.PopupWindow)3 AppCompatResources (androidx.appcompat.content.res.AppCompatResources)3 ActionMode (androidx.appcompat.view.ActionMode)3 ContextThemeWrapper (androidx.appcompat.view.ContextThemeWrapper)3 StandaloneActionMode (androidx.appcompat.view.StandaloneActionMode)3 MenuView (androidx.appcompat.view.menu.MenuView)3 ActionBarContextView (androidx.appcompat.widget.ActionBarContextView)3 VectorEnabledTintResources (androidx.appcompat.widget.VectorEnabledTintResources)3 ViewPropertyAnimatorListenerAdapter (androidx.core.view.ViewPropertyAnimatorListenerAdapter)3 ActionMode (android.view.ActionMode)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1