use of android.transition.TransitionValues in project Telegram-FOSS by Telegram-FOSS-Team.
the class ScrollSlidingTabStrip method beginUpdate.
public void beginUpdate(boolean animated) {
prevTypes = tabTypes;
tabTypes = new HashMap<>();
futureTabsPositions.clear();
tabCount = 0;
if (animated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
final AutoTransition transition = new AutoTransition();
transition.setDuration(250);
transition.setOrdering(TransitionSet.ORDERING_TOGETHER);
transition.addTransition(new Transition() {
@Override
public void captureStartValues(TransitionValues transitionValues) {
}
@Override
public void captureEndValues(TransitionValues transitionValues) {
}
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
final ValueAnimator invalidateAnimator = ValueAnimator.ofFloat(0, 1);
invalidateAnimator.addUpdateListener(a -> invalidate());
return invalidateAnimator;
}
});
TransitionManager.beginDelayedTransition(tabsContainer, transition);
}
}
use of android.transition.TransitionValues in project Telegram-FOSS by Telegram-FOSS-Team.
the class VoIPFragment method updateButtons.
private void updateButtons(boolean animated) {
VoIPService service = VoIPService.getSharedInstance();
if (service == null) {
return;
}
if (animated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
TransitionSet transitionSet = new TransitionSet();
Visibility visibility = new Visibility() {
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, AndroidUtilities.dp(100), 0);
if (view instanceof VoIPToggleButton) {
view.setTranslationY(AndroidUtilities.dp(100));
animator.setStartDelay(((VoIPToggleButton) view).animationDelay);
}
return animator;
}
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
return ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, view.getTranslationY(), AndroidUtilities.dp(100));
}
};
transitionSet.addTransition(visibility.setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT)).addTransition(new ChangeBounds().setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT));
transitionSet.excludeChildren(VoIPToggleButton.class, true);
TransitionManager.beginDelayedTransition(buttonsLayout, transitionSet);
}
if (currentState == VoIPService.STATE_WAITING_INCOMING || currentState == VoIPService.STATE_BUSY) {
if (service.privateCall != null && service.privateCall.video && currentState == VoIPService.STATE_WAITING_INCOMING) {
if (!service.isScreencast() && (currentUserIsVideo || callingUserIsVideo)) {
setFrontalCameraAction(bottomButtons[0], service, animated);
if (uiVisible) {
speakerPhoneIcon.animate().alpha(1f).start();
}
} else {
setSpeakerPhoneAction(bottomButtons[0], service, animated);
speakerPhoneIcon.animate().alpha(0).start();
}
setVideoAction(bottomButtons[1], service, animated);
setMicrohoneAction(bottomButtons[2], service, animated);
} else {
bottomButtons[0].setVisibility(View.GONE);
bottomButtons[1].setVisibility(View.GONE);
bottomButtons[2].setVisibility(View.GONE);
}
bottomButtons[3].setVisibility(View.GONE);
} else {
if (instance == null) {
return;
}
if (!service.isScreencast() && (currentUserIsVideo || callingUserIsVideo)) {
setFrontalCameraAction(bottomButtons[0], service, animated);
if (uiVisible) {
speakerPhoneIcon.setTag(1);
speakerPhoneIcon.animate().alpha(1f).start();
}
} else {
setSpeakerPhoneAction(bottomButtons[0], service, animated);
speakerPhoneIcon.setTag(null);
speakerPhoneIcon.animate().alpha(0f).start();
}
setVideoAction(bottomButtons[1], service, animated);
setMicrohoneAction(bottomButtons[2], service, animated);
bottomButtons[3].setData(R.drawable.calls_decline, Color.WHITE, 0xFFF01D2C, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), false, animated);
bottomButtons[3].setOnClickListener(view -> {
if (VoIPService.getSharedInstance() != null) {
VoIPService.getSharedInstance().hangUp();
}
});
}
int animationDelay = 0;
for (int i = 0; i < 4; i++) {
if (bottomButtons[i].getVisibility() == View.VISIBLE) {
bottomButtons[i].animationDelay = animationDelay;
animationDelay += 16;
}
}
updateSpeakerPhoneIcon();
}
use of android.transition.TransitionValues in project android_packages_apps_Dialer by LineageOS.
the class Bubble method showText.
/**
* Display text in the main bubble. The bubble's drawer is not expandable while text is showing,
* and the drawer will be closed if already open.
*
* @param text the text to display to the user
*/
public void showText(@NonNull CharSequence text) {
textShowing = true;
if (expanded) {
startCollapse(CollapseEnd.NOTHING);
doShowText(text);
} else {
// Need to transition from old bounds to new bounds manually
ChangeOnScreenBounds transition = new ChangeOnScreenBounds();
// Prepare and capture start values
TransitionValues startValues = new TransitionValues();
startValues.view = viewHolder.getPrimaryButton();
transition.addTarget(startValues.view);
transition.captureStartValues(startValues);
doResize(() -> {
doShowText(text);
// Hide the text so we can animate it in
viewHolder.getPrimaryText().setAlpha(0);
ViewAnimator primaryButton = viewHolder.getPrimaryButton();
// Cancel the automatic transition scheduled in doShowText
TransitionManager.endTransitions((ViewGroup) primaryButton.getParent());
primaryButton.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
primaryButton.getViewTreeObserver().removeOnPreDrawListener(this);
// Prepare and capture end values
TransitionValues endValues = new TransitionValues();
endValues.view = primaryButton;
transition.addTarget(endValues.view);
transition.captureEndValues(endValues);
// animate the primary button bounds change
Animator bounds = transition.createAnimator(primaryButton, startValues, endValues);
// Animate the text in
Animator alpha = ObjectAnimator.ofFloat(viewHolder.getPrimaryText(), View.ALPHA, 1f);
AnimatorSet set = new AnimatorSet();
set.play(bounds).before(alpha);
set.start();
return false;
}
});
});
}
handler.removeCallbacks(null);
handler.postDelayed(() -> {
textShowing = false;
if (hideAfterText) {
hide();
} else {
doResize(() -> viewHolder.getPrimaryButton().setDisplayedChild(ViewHolder.CHILD_INDEX_ICON));
}
}, SHOW_TEXT_DURATION_MILLIS);
}
use of android.transition.TransitionValues in project Telegram-FOSS by Telegram-FOSS-Team.
the class ActionBarMenuItem method onFiltersChanged.
private void onFiltersChanged() {
boolean visible = !currentSearchFilters.isEmpty();
ArrayList<FiltersView.MediaFilterData> localFilters = new ArrayList<>(currentSearchFilters);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && searchContainer.getTag() != null) {
TransitionSet transition = new TransitionSet();
ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setDuration(150);
transition.addTransition(new Visibility() {
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
if (view instanceof SearchFilterView) {
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1f), ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f, 1f), ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f, 1f));
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
return set;
}
return ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1f);
}
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
if (view instanceof SearchFilterView) {
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), 0f), ObjectAnimator.ofFloat(view, View.SCALE_X, view.getScaleX(), 0.5f), ObjectAnimator.ofFloat(view, View.SCALE_Y, view.getScaleX(), 0.5f));
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
return set;
}
return ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0);
}
}.setDuration(150)).addTransition(changeBounds);
transition.setOrdering(TransitionSet.ORDERING_TOGETHER);
transition.setInterpolator(CubicBezierInterpolator.EASE_OUT);
int selectedAccount = UserConfig.selectedAccount;
transition.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
notificationIndex = NotificationCenter.getInstance(selectedAccount).setAnimationInProgress(notificationIndex, null);
}
@Override
public void onTransitionEnd(Transition transition) {
NotificationCenter.getInstance(selectedAccount).onAnimationFinish(notificationIndex);
}
@Override
public void onTransitionCancel(Transition transition) {
NotificationCenter.getInstance(selectedAccount).onAnimationFinish(notificationIndex);
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
TransitionManager.beginDelayedTransition(searchFilterLayout, transition);
}
for (int i = 0; i < searchFilterLayout.getChildCount(); i++) {
boolean removed = localFilters.remove(((SearchFilterView) searchFilterLayout.getChildAt(i)).getFilter());
if (!removed) {
searchFilterLayout.removeViewAt(i);
i--;
}
}
for (int i = 0; i < localFilters.size(); i++) {
SearchFilterView searchFilterView = new SearchFilterView(getContext(), resourcesProvider);
searchFilterView.setData(localFilters.get(i));
searchFilterView.setOnClickListener(view -> {
int index = currentSearchFilters.indexOf(searchFilterView.getFilter());
if (selectedFilterIndex != index) {
selectedFilterIndex = index;
onFiltersChanged();
return;
}
if (searchFilterView.getFilter().removable) {
if (!searchFilterView.selectedForDelete) {
searchFilterView.setSelectedForDelete(true);
} else {
FiltersView.MediaFilterData filterToRemove = searchFilterView.getFilter();
removeSearchFilter(filterToRemove);
if (listener != null) {
listener.onSearchFilterCleared(filterToRemove);
listener.onTextChanged(searchField);
}
}
}
});
searchFilterLayout.addView(searchFilterView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 6, 0));
}
for (int i = 0; i < searchFilterLayout.getChildCount(); i++) {
((SearchFilterView) searchFilterLayout.getChildAt(i)).setExpanded(i == selectedFilterIndex);
}
searchFilterLayout.setTag(visible ? 1 : null);
float oldX = searchField.getX();
if (searchContainer.getTag() != null) {
searchField.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
searchField.getViewTreeObserver().removeOnPreDrawListener(this);
if (searchField.getX() != oldX) {
searchField.setTranslationX(oldX - searchField.getX());
}
searchField.animate().translationX(0).setDuration(250).setStartDelay(0).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
return true;
}
});
}
checkClearButton();
}
use of android.transition.TransitionValues in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method updateTabs.
private void updateTabs(boolean animated) {
if (scrollSlidingTextTabStrip == null) {
return;
}
if (!delegate.isFragmentOpened()) {
animated = false;
}
int changed = 0;
if ((chatUsersAdapter.chatInfo == null) == scrollSlidingTextTabStrip.hasTab(7)) {
changed++;
}
if ((hasMedia[0] <= 0) == scrollSlidingTextTabStrip.hasTab(0)) {
changed++;
}
if ((hasMedia[1] <= 0) == scrollSlidingTextTabStrip.hasTab(1)) {
changed++;
}
if (!DialogObject.isEncryptedDialog(dialog_id)) {
if ((hasMedia[3] <= 0) == scrollSlidingTextTabStrip.hasTab(3)) {
changed++;
}
if ((hasMedia[4] <= 0) == scrollSlidingTextTabStrip.hasTab(4)) {
changed++;
}
} else {
if ((hasMedia[4] <= 0) == scrollSlidingTextTabStrip.hasTab(4)) {
changed++;
}
}
if ((hasMedia[2] <= 0) == scrollSlidingTextTabStrip.hasTab(2)) {
changed++;
}
if ((hasMedia[5] <= 0) == scrollSlidingTextTabStrip.hasTab(5)) {
changed++;
}
if ((hasMedia[6] <= 0) == scrollSlidingTextTabStrip.hasTab(6)) {
changed++;
}
if (changed > 0) {
if (animated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
final TransitionSet transitionSet = new TransitionSet();
transitionSet.setOrdering(TransitionSet.ORDERING_TOGETHER);
transitionSet.addTransition(new ChangeBounds());
transitionSet.addTransition(new Visibility() {
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1f), ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f, 1f), ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f, 1f));
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
return set;
}
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), 0f), ObjectAnimator.ofFloat(view, View.SCALE_X, view.getScaleX(), 0.5f), ObjectAnimator.ofFloat(view, View.SCALE_Y, view.getScaleX(), 0.5f));
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
return set;
}
});
transitionSet.setDuration(200);
TransitionManager.beginDelayedTransition(scrollSlidingTextTabStrip.getTabsContainer(), transitionSet);
scrollSlidingTextTabStrip.recordIndicatorParams();
}
SparseArray<View> idToView = scrollSlidingTextTabStrip.removeTabs();
if (changed > 3) {
idToView = null;
}
if (chatUsersAdapter.chatInfo != null) {
if (!scrollSlidingTextTabStrip.hasTab(7)) {
scrollSlidingTextTabStrip.addTextTab(7, LocaleController.getString("GroupMembers", R.string.GroupMembers), idToView);
}
}
if (hasMedia[0] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(0)) {
if (hasMedia[1] == 0 && hasMedia[2] == 0 && hasMedia[3] == 0 && hasMedia[4] == 0 && hasMedia[5] == 0 && hasMedia[6] == 0 && chatUsersAdapter.chatInfo == null) {
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("SharedMediaTabFull2", R.string.SharedMediaTabFull2), idToView);
} else {
scrollSlidingTextTabStrip.addTextTab(0, LocaleController.getString("SharedMediaTab2", R.string.SharedMediaTab2), idToView);
}
}
}
if (hasMedia[1] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(1)) {
scrollSlidingTextTabStrip.addTextTab(1, LocaleController.getString("SharedFilesTab2", R.string.SharedFilesTab2), idToView);
}
}
if (!DialogObject.isEncryptedDialog(dialog_id)) {
if (hasMedia[3] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(3)) {
scrollSlidingTextTabStrip.addTextTab(3, LocaleController.getString("SharedLinksTab2", R.string.SharedLinksTab2), idToView);
}
}
if (hasMedia[4] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(4)) {
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab2", R.string.SharedMusicTab2), idToView);
}
}
} else {
if (hasMedia[4] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(4)) {
scrollSlidingTextTabStrip.addTextTab(4, LocaleController.getString("SharedMusicTab2", R.string.SharedMusicTab2), idToView);
}
}
}
if (hasMedia[2] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(2)) {
scrollSlidingTextTabStrip.addTextTab(2, LocaleController.getString("SharedVoiceTab2", R.string.SharedVoiceTab2), idToView);
}
}
if (hasMedia[5] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(5)) {
scrollSlidingTextTabStrip.addTextTab(5, LocaleController.getString("SharedGIFsTab2", R.string.SharedGIFsTab2), idToView);
}
}
if (hasMedia[6] > 0) {
if (!scrollSlidingTextTabStrip.hasTab(6)) {
scrollSlidingTextTabStrip.addTextTab(6, LocaleController.getString("SharedGroupsTab2", R.string.SharedGroupsTab2), idToView);
}
}
}
int id = scrollSlidingTextTabStrip.getCurrentTabId();
if (id >= 0) {
mediaPages[0].selectedType = id;
}
scrollSlidingTextTabStrip.finishAddingTabs();
}
Aggregations