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;
}
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;
}
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;
}
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);
}
}
Aggregations