Launch channel settings as half sheet
If opening app has requested only a subset of fields Test: manual - launch from an app, filtered and unfiltered, for normal channels and conversations Bug: 177246841 Change-Id: Ifd70478101d1ea1340d2ecc55033fab55e65ca92 Change-Id: I5194b959c82b2cfa7990c84285aaf69464cff3a8
This commit is contained in:
@@ -18,6 +18,9 @@ package com.android.settings.notification.app;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
@@ -39,8 +42,13 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -85,6 +93,20 @@ abstract public class NotificationSettings extends DashboardFragment {
|
||||
protected Intent mIntent;
|
||||
protected Bundle mArgs;
|
||||
|
||||
private ViewGroup mLayoutView;
|
||||
private static final int DURATION_ANIMATE_PANEL_EXPAND_MS = 250;
|
||||
|
||||
private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
animateIn();
|
||||
if (mLayoutView != null) {
|
||||
mLayoutView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -187,6 +209,50 @@ abstract public class NotificationSettings extends DashboardFragment {
|
||||
collectConfigActivities();
|
||||
}
|
||||
|
||||
protected void animatePanel() {
|
||||
if (mPreferenceFilter != null) {
|
||||
mLayoutView = getActivity().findViewById(R.id.main_content);
|
||||
mLayoutView.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Animate a Panel onto the screen.
|
||||
* <p>
|
||||
* Takes the entire panel and animates in from behind the navigation bar.
|
||||
* <p>
|
||||
* Relies on the Panel being having a fixed height to begin the animation.
|
||||
*/
|
||||
private void animateIn() {
|
||||
final AnimatorSet animatorSet = buildAnimatorSet(mLayoutView,
|
||||
mLayoutView.getHeight() /* startY */, 0.0f /* endY */,
|
||||
0.0f /* startAlpha */, 1.0f /* endAlpha */,
|
||||
DURATION_ANIMATE_PANEL_EXPAND_MS);
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setFloatValues(0.0f, 1.0f);
|
||||
animatorSet.play(animator);
|
||||
animatorSet.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an {@link AnimatorSet} to animate the Panel, {@param parentView} in or out of the
|
||||
* screen, based on the positional parameters {@param startY}, {@param endY}, the parameters
|
||||
* for alpha changes {@param startAlpha}, {@param endAlpha}, and the {@param duration} in
|
||||
* milliseconds.
|
||||
*/
|
||||
@NonNull
|
||||
private static AnimatorSet buildAnimatorSet(@NonNull View targetView,
|
||||
float startY, float endY,
|
||||
float startAlpha, float endAlpha, int duration) {
|
||||
final AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.setDuration(duration);
|
||||
animatorSet.setInterpolator(new DecelerateInterpolator());
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(targetView, View.TRANSLATION_Y, startY, endY),
|
||||
ObjectAnimator.ofFloat(targetView, View.ALPHA, startAlpha, endAlpha));
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private void loadPreferencesFilter() {
|
||||
Intent intent = getActivity().getIntent();
|
||||
mPreferenceFilter = intent != null
|
||||
|
||||
Reference in New Issue
Block a user