Search in sources :

Example 6 with AutoTransition

use of androidx.transition.AutoTransition in project Signal-Android by signalapp.

the class WebRtcCallView method fadeInNewUiState.

private void fadeInNewUiState(boolean useSmallMargins, boolean showSmallHeader) {
    Transition transition = new AutoTransition().setDuration(TRANSITION_DURATION_MILLIS);
    TransitionManager.beginDelayedTransition(parent, transition);
    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(parent);
    for (View view : SetUtil.difference(allTimeVisibleViews, visibleViewSet)) {
        constraintSet.setVisibility(view.getId(), ConstraintSet.GONE);
    }
    for (View view : visibleViewSet) {
        constraintSet.setVisibility(view.getId(), ConstraintSet.VISIBLE);
        if (adjustableMarginsSet.contains(view)) {
            constraintSet.setMargin(view.getId(), ConstraintSet.END, ViewUtil.dpToPx(useSmallMargins ? SMALL_ONGOING_CALL_BUTTON_MARGIN_DP : LARGE_ONGOING_CALL_BUTTON_MARGIN_DP));
        }
    }
    adjustParticipantsRecycler(constraintSet);
    constraintSet.applyTo(parent);
    if (showSmallHeader) {
        smallHeaderConstraints.setVisibility(incomingRingStatus.getId(), visibleViewSet.contains(incomingRingStatus) ? View.VISIBLE : View.GONE);
        smallHeaderConstraints.applyTo(toolbar);
    } else {
        largeHeaderConstraints.setVisibility(incomingRingStatus.getId(), visibleViewSet.contains(incomingRingStatus) ? View.VISIBLE : View.GONE);
        largeHeaderConstraints.applyTo(toolbar);
    }
}
Also used : AutoTransition(androidx.transition.AutoTransition) Transition(androidx.transition.Transition) AutoTransition(androidx.transition.AutoTransition) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView)

Example 7 with AutoTransition

use of androidx.transition.AutoTransition in project Signal-Android by signalapp.

the class WebRtcCallView method fadeControls.

private void fadeControls(int visibility) {
    controlsVisible = visibility == VISIBLE;
    Transition transition = new AutoTransition().setOrdering(TransitionSet.ORDERING_TOGETHER).setDuration(TRANSITION_DURATION_MILLIS);
    TransitionManager.endTransitions(parent);
    if (controlsListener != null) {
        if (controlsVisible) {
            controlsListener.showSystemUI();
        } else {
            controlsListener.hideSystemUI();
        }
    }
    TransitionManager.beginDelayedTransition(parent, transition);
    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(parent);
    for (View view : controlsToFade()) {
        constraintSet.setVisibility(view.getId(), visibility);
    }
    adjustParticipantsRecycler(constraintSet);
    constraintSet.applyTo(parent);
    layoutParticipants();
}
Also used : AutoTransition(androidx.transition.AutoTransition) Transition(androidx.transition.Transition) AutoTransition(androidx.transition.AutoTransition) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AvatarImageView(org.thoughtcrime.securesms.components.AvatarImageView)

Example 8 with AutoTransition

use of androidx.transition.AutoTransition in project Signal-Android by signalapp.

the class ContactSelectionListFragment method setChipGroupVisibility.

private void setChipGroupVisibility(int visibility) {
    if (!safeArguments().getBoolean(DISPLAY_CHIPS, requireActivity().getIntent().getBooleanExtra(DISPLAY_CHIPS, true))) {
        return;
    }
    AutoTransition transition = new AutoTransition();
    transition.setDuration(CHIP_GROUP_REVEAL_DURATION_MS);
    transition.excludeChildren(recyclerView, true);
    transition.excludeTarget(recyclerView, true);
    TransitionManager.beginDelayedTransition(constraintLayout, transition);
    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(constraintLayout);
    constraintSet.setVisibility(R.id.chipGroupScrollContainer, visibility);
    constraintSet.applyTo(constraintLayout);
}
Also used : AutoTransition(androidx.transition.AutoTransition) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet)

Example 9 with AutoTransition

use of androidx.transition.AutoTransition in project uCrop by Yalantis.

the class UCropFragment method setupViews.

public void setupViews(View view, Bundle args) {
    mActiveControlsWidgetColor = args.getInt(UCrop.Options.EXTRA_UCROP_COLOR_CONTROLS_WIDGET_ACTIVE, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget_active));
    mLogoColor = args.getInt(UCrop.Options.EXTRA_UCROP_LOGO_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_default_logo));
    mShowBottomControls = !args.getBoolean(UCrop.Options.EXTRA_HIDE_BOTTOM_CONTROLS, false);
    mRootViewBackgroundColor = args.getInt(UCrop.Options.EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.ucrop_color_crop_background));
    initiateRootViews(view);
    callback.loadingProgress(true);
    if (mShowBottomControls) {
        ViewGroup wrapper = view.findViewById(R.id.controls_wrapper);
        wrapper.setVisibility(View.VISIBLE);
        LayoutInflater.from(getContext()).inflate(R.layout.ucrop_controls, wrapper, true);
        mControlsTransition = new AutoTransition();
        mControlsTransition.setDuration(CONTROLS_ANIMATION_DURATION);
        mWrapperStateAspectRatio = view.findViewById(R.id.state_aspect_ratio);
        mWrapperStateAspectRatio.setOnClickListener(mStateClickListener);
        mWrapperStateRotate = view.findViewById(R.id.state_rotate);
        mWrapperStateRotate.setOnClickListener(mStateClickListener);
        mWrapperStateScale = view.findViewById(R.id.state_scale);
        mWrapperStateScale.setOnClickListener(mStateClickListener);
        mLayoutAspectRatio = view.findViewById(R.id.layout_aspect_ratio);
        mLayoutRotate = view.findViewById(R.id.layout_rotate_wheel);
        mLayoutScale = view.findViewById(R.id.layout_scale_wheel);
        setupAspectRatioWidget(args, view);
        setupRotateWidget(view);
        setupScaleWidget(view);
        setupStatesWrapper(view);
    } else {
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.findViewById(R.id.ucrop_frame).getLayoutParams();
        params.bottomMargin = 0;
        view.findViewById(R.id.ucrop_frame).requestLayout();
    }
}
Also used : AutoTransition(androidx.transition.AutoTransition) ViewGroup(android.view.ViewGroup) RelativeLayout(android.widget.RelativeLayout)

Example 10 with AutoTransition

use of androidx.transition.AutoTransition in project Alarmio by TheAndroidMaster.

the class AlarmsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (getItemViewType(position) == 0) {
        final TimerViewHolder timerHolder = (TimerViewHolder) holder;
        if (timerHolder.runnable != null)
            timerHolder.handler.removeCallbacks(timerHolder.runnable);
        timerHolder.runnable = new Runnable() {

            @Override
            public void run() {
                try {
                    TimerData timer = getTimer(timerHolder.getAdapterPosition());
                    String text = FormatUtils.formatMillis(timer.getRemainingMillis());
                    timerHolder.time.setText(text.substring(0, text.length() - 3));
                    timerHolder.progress.update(1 - ((float) timer.getRemainingMillis() / timer.getDuration()));
                    timerHolder.handler.postDelayed(this, 1000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        timerHolder.stop.setColorFilter(textColorPrimary);
        timerHolder.stop.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                TimerData timer = getTimer(timerHolder.getAdapterPosition());
                alarmio.removeTimer(timer);
            }
        });
        timerHolder.handler.post(timerHolder.runnable);
    } else {
        final AlarmViewHolder alarmHolder = (AlarmViewHolder) holder;
        final boolean isExpanded = position == expandedPosition;
        AlarmData alarm = getAlarm(position);
        alarmHolder.name.setFocusable(isExpanded);
        alarmHolder.name.setEnabled(isExpanded);
        alarmHolder.name.clearFocus();
        alarmHolder.nameUnderline.setVisibility(isExpanded ? View.VISIBLE : View.GONE);
        alarmHolder.name.setText(alarm.getName(alarmio));
        alarmHolder.name.addTextChangedListener(new TextWatcher() {

            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                getAlarm(alarmHolder.getAdapterPosition()).setName(alarmio, alarmHolder.name.getText().toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {
            }
        });
        alarmHolder.enable.setOnCheckedChangeListener(null);
        alarmHolder.enable.setChecked(alarm.isEnabled);
        alarmHolder.enable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                getAlarm(alarmHolder.getAdapterPosition()).setEnabled(alarmio, alarmManager, b);
            }
        });
        alarmHolder.time.setText(FormatUtils.formatShort(alarmio, alarm.time.getTime()));
        alarmHolder.time.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                new AestheticTimeSheetPickerDialog(view.getContext(), alarm.time.get(Calendar.HOUR_OF_DAY), alarm.time.get(Calendar.MINUTE)).setListener(new PickerDialog.OnSelectedListener<LinearTimePickerView>() {

                    @Override
                    public void onSelect(PickerDialog<LinearTimePickerView> dialog, LinearTimePickerView view) {
                        AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                        alarm.time.set(Calendar.HOUR_OF_DAY, view.getHourOfDay());
                        alarm.time.set(Calendar.MINUTE, view.getMinute());
                        alarm.setTime(alarmio, alarmManager, alarm.time.getTimeInMillis());
                        alarmHolder.time.setText(FormatUtils.formatShort(alarmio, alarm.time.getTime()));
                    }

                    @Override
                    public void onCancel(PickerDialog<LinearTimePickerView> dialog) {
                    }
                }).show();
            }
        });
        alarmHolder.indicators.setVisibility(isExpanded ? View.GONE : View.VISIBLE);
        if (isExpanded) {
            alarmHolder.repeat.setOnCheckedChangeListener(null);
            alarmHolder.repeat.setChecked(alarm.isRepeat());
            alarmHolder.repeat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                    for (int i = 0; i < 7; i++) {
                        alarm.days[i] = b;
                    }
                    alarm.setDays(alarmio, alarm.days);
                    Transition transition = new AutoTransition();
                    transition.setDuration(150);
                    TransitionManager.beginDelayedTransition(recycler, transition);
                    notifyDataSetChanged();
                }
            });
            alarmHolder.days.setVisibility(alarm.isRepeat() ? View.VISIBLE : View.GONE);
            DaySwitch.OnCheckedChangeListener listener = new DaySwitch.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(DaySwitch daySwitch, boolean b) {
                    AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                    alarm.days[alarmHolder.days.indexOfChild(daySwitch)] = b;
                    alarm.setDays(alarmio, alarm.days);
                    if (!alarm.isRepeat())
                        notifyItemChanged(alarmHolder.getAdapterPosition());
                }
            };
            for (int i = 0; i < 7; i++) {
                DaySwitch daySwitch = (DaySwitch) alarmHolder.days.getChildAt(i);
                daySwitch.setChecked(alarm.days[i]);
                daySwitch.setOnCheckedChangeListener(listener);
                switch(i) {
                    case 0:
                    case 6:
                        daySwitch.setText("S");
                        break;
                    case 1:
                        daySwitch.setText("M");
                        break;
                    case 2:
                    case 4:
                        daySwitch.setText("T");
                        break;
                    case 3:
                        daySwitch.setText("W");
                        break;
                    case 5:
                        daySwitch.setText("F");
                }
            }
            alarmHolder.ringtoneImage.setImageResource(alarm.hasSound() ? R.drawable.ic_ringtone : R.drawable.ic_ringtone_disabled);
            alarmHolder.ringtoneImage.setAlpha(alarm.hasSound() ? 1 : 0.333f);
            alarmHolder.ringtoneText.setText(alarm.hasSound() ? alarm.getSound().getName() : alarmio.getString(R.string.title_sound_none));
            alarmHolder.ringtone.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    SoundChooserDialog dialog = new SoundChooserDialog();
                    dialog.setListener(new SoundChooserListener() {

                        @Override
                        public void onSoundChosen(SoundData sound) {
                            int position = alarmHolder.getAdapterPosition();
                            AlarmData alarm = getAlarm(position);
                            alarm.setSound(alarmio, sound);
                            notifyItemChanged(position);
                        }
                    });
                    dialog.show(fragmentManager, null);
                }
            });
            AnimatedVectorDrawableCompat vibrateDrawable = AnimatedVectorDrawableCompat.create(alarmio, alarm.isVibrate ? R.drawable.ic_vibrate_to_none : R.drawable.ic_none_to_vibrate);
            alarmHolder.vibrateImage.setImageDrawable(vibrateDrawable);
            alarmHolder.vibrateImage.setAlpha(alarm.isVibrate ? 1 : 0.333f);
            alarmHolder.vibrate.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                    alarm.setVibrate(alarmio, !alarm.isVibrate);
                    AnimatedVectorDrawableCompat vibrateDrawable = AnimatedVectorDrawableCompat.create(alarmio, alarm.isVibrate ? R.drawable.ic_none_to_vibrate : R.drawable.ic_vibrate_to_none);
                    if (vibrateDrawable != null) {
                        alarmHolder.vibrateImage.setImageDrawable(vibrateDrawable);
                        vibrateDrawable.start();
                    } else
                        alarmHolder.vibrateImage.setImageResource(alarm.isVibrate ? R.drawable.ic_vibrate : R.drawable.ic_vibrate_none);
                    alarmHolder.vibrateImage.animate().alpha(alarm.isVibrate ? 1 : 0.333f).setDuration(250).start();
                    if (alarm.isVibrate)
                        view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                }
            });
        } else {
            alarmHolder.repeatIndicator.setAlpha(alarm.isRepeat() ? 1 : 0.333f);
            alarmHolder.soundIndicator.setAlpha(alarm.hasSound() ? 1 : 0.333f);
            alarmHolder.vibrateIndicator.setAlpha(alarm.isVibrate ? 1 : 0.333f);
        }
        alarmHolder.expandImage.animate().rotationX(isExpanded ? 180 : 0).start();
        alarmHolder.delete.setVisibility(isExpanded ? View.VISIBLE : View.GONE);
        alarmHolder.delete.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                AlarmData alarm = getAlarm(alarmHolder.getAdapterPosition());
                new AlertDialog(view.getContext()).setContent(alarmio.getString(R.string.msg_delete_confirmation, alarm.getName(alarmio))).setListener(new AlertDialog.Listener() {

                    @Override
                    public void onDismiss(AlertDialog dialog, boolean ok) {
                        if (ok)
                            alarmio.removeAlarm(getAlarm(alarmHolder.getAdapterPosition()));
                    }
                }).show();
            }
        });
        alarmHolder.repeat.setTextColor(textColorPrimary);
        alarmHolder.delete.setTextColor(textColorPrimary);
        alarmHolder.ringtoneImage.setColorFilter(textColorPrimary);
        alarmHolder.vibrateImage.setColorFilter(textColorPrimary);
        alarmHolder.expandImage.setColorFilter(textColorPrimary);
        alarmHolder.repeatIndicator.setColorFilter(textColorPrimary);
        alarmHolder.soundIndicator.setColorFilter(textColorPrimary);
        alarmHolder.vibrateIndicator.setColorFilter(textColorPrimary);
        alarmHolder.nameUnderline.setBackgroundColor(textColorPrimary);
        int visibility = isExpanded ? View.VISIBLE : View.GONE;
        if (visibility != alarmHolder.extra.getVisibility()) {
            alarmHolder.extra.setVisibility(visibility);
            Aesthetic.Companion.get().colorPrimary().take(1).subscribe(new Consumer<Integer>() {

                @Override
                public void accept(Integer integer) throws Exception {
                    ValueAnimator animator = ValueAnimator.ofObject(new ArgbEvaluator(), isExpanded ? integer : colorForeground, isExpanded ? colorForeground : integer);
                    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                        @Override
                        public void onAnimationUpdate(ValueAnimator animation) {
                            alarmHolder.itemView.setBackgroundColor((int) animation.getAnimatedValue());
                        }
                    });
                    animator.addListener(new Animator.AnimatorListener() {

                        @Override
                        public void onAnimationStart(Animator animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            alarmHolder.itemView.setBackgroundColor(isExpanded ? colorForeground : Color.TRANSPARENT);
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animator animation) {
                        }
                    });
                    animator.start();
                }
            });
            ValueAnimator animator = ValueAnimator.ofFloat(isExpanded ? 0 : ConversionUtils.dpToPx(2), isExpanded ? ConversionUtils.dpToPx(2) : 0);
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    ViewCompat.setElevation(alarmHolder.itemView, (float) animation.getAnimatedValue());
                }
            });
            animator.start();
        } else {
            alarmHolder.itemView.setBackgroundColor(isExpanded ? colorForeground : Color.TRANSPARENT);
            ViewCompat.setElevation(alarmHolder.itemView, isExpanded ? ConversionUtils.dpToPx(2) : 0);
        }
        alarmHolder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                expandedPosition = isExpanded ? -1 : alarmHolder.getAdapterPosition();
                Transition transition = new AutoTransition();
                transition.setDuration(250);
                TransitionManager.beginDelayedTransition(recycler, transition);
                notifyDataSetChanged();
            }
        });
    }
}
Also used : AlertDialog(james.alarmio.dialogs.AlertDialog) SoundChooserListener(james.alarmio.interfaces.SoundChooserListener) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) SoundData(james.alarmio.data.SoundData) DaySwitch(james.alarmio.views.DaySwitch) AutoTransition(androidx.transition.AutoTransition) AestheticTimeSheetPickerDialog(james.alarmio.dialogs.AestheticTimeSheetPickerDialog) ImageView(android.widget.ImageView) LinearTimePickerView(me.jfenn.timedatepickers.views.LinearTimePickerView) View(android.view.View) ProgressLineView(james.alarmio.views.ProgressLineView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) SoundChooserDialog(james.alarmio.dialogs.SoundChooserDialog) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) TimerData(james.alarmio.data.TimerData) PickerDialog(me.jfenn.timedatepickers.dialogs.PickerDialog) AestheticTimeSheetPickerDialog(james.alarmio.dialogs.AestheticTimeSheetPickerDialog) AutoTransition(androidx.transition.AutoTransition) Transition(androidx.transition.Transition) AnimatedVectorDrawableCompat(androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat) CompoundButton(android.widget.CompoundButton) AlarmData(james.alarmio.data.AlarmData) LinearTimePickerView(me.jfenn.timedatepickers.views.LinearTimePickerView)

Aggregations

AutoTransition (androidx.transition.AutoTransition)11 ConstraintSet (androidx.constraintlayout.widget.ConstraintSet)8 Transition (androidx.transition.Transition)7 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 AvatarImageView (org.thoughtcrime.securesms.components.AvatarImageView)4 ViewGroup (android.view.ViewGroup)2 Animator (android.animation.Animator)1 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 CompoundButton (android.widget.CompoundButton)1 RelativeLayout (android.widget.RelativeLayout)1 AnimatedVectorDrawableCompat (androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat)1 AlarmData (james.alarmio.data.AlarmData)1 SoundData (james.alarmio.data.SoundData)1 TimerData (james.alarmio.data.TimerData)1