Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Snippets Groups Projects
Commit 3d7510c3 authored by Daniel Sandler's avatar Daniel Sandler Committed by android-build-merger
Browse files

Merge "Remove direct-share target row animations and limit to one row." into pi-dev

am: d8f3889b

Change-Id: I02947ea217d0ae98f792a63fd24542aed1567afb
parents 830bf102 d8f3889b
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,7 @@ import android.widget.Space; ...@@ -76,6 +76,7 @@ import android.widget.Space;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ResolverActivity;
import com.android.internal.app.ResolverActivity.TargetInfo; import com.android.internal.app.ResolverActivity.TargetInfo;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
...@@ -932,7 +933,7 @@ public class ChooserActivity extends ResolverActivity { ...@@ -932,7 +933,7 @@ public class ChooserActivity extends ResolverActivity {
public static final int TARGET_SERVICE = 1; public static final int TARGET_SERVICE = 1;
public static final int TARGET_STANDARD = 2; public static final int TARGET_STANDARD = 2;
private static final int MAX_SERVICE_TARGETS = 8; private static final int MAX_SERVICE_TARGETS = 4;
private static final int MAX_TARGETS_PER_SERVICE = 4; private static final int MAX_TARGETS_PER_SERVICE = 4;
private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>(); private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
...@@ -1189,123 +1190,20 @@ public class ChooserActivity extends ResolverActivity { ...@@ -1189,123 +1190,20 @@ public class ChooserActivity extends ResolverActivity {
} }
} }
static class RowScale {
private static final int DURATION = 400;
float mScale;
ChooserRowAdapter mAdapter;
private final ObjectAnimator mAnimator;
public static final FloatProperty<RowScale> PROPERTY =
new FloatProperty<RowScale>("scale") {
@Override
public void setValue(RowScale object, float value) {
object.mScale = value;
object.mAdapter.notifyDataSetChanged();
}
@Override
public Float get(RowScale object) {
return object.mScale;
}
};
public RowScale(@NonNull ChooserRowAdapter adapter, float from, float to) {
mAdapter = adapter;
mScale = from;
if (from == to) {
mAnimator = null;
return;
}
mAnimator = ObjectAnimator.ofFloat(this, PROPERTY, from, to)
.setDuration(DURATION);
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mAdapter.onAnimationStart();
}
@Override
public void onAnimationEnd(Animator animation) {
mAdapter.onAnimationEnd();
}
});
}
public RowScale setInterpolator(Interpolator interpolator) {
if (mAnimator != null) {
mAnimator.setInterpolator(interpolator);
}
return this;
}
public float get() {
return mScale;
}
public void startAnimation() {
if (mAnimator != null) {
mAnimator.start();
}
}
public void cancelAnimation() {
if (mAnimator != null) {
mAnimator.cancel();
}
}
}
class ChooserRowAdapter extends BaseAdapter { class ChooserRowAdapter extends BaseAdapter {
private ChooserListAdapter mChooserListAdapter; private ChooserListAdapter mChooserListAdapter;
private final LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
private final int mColumnCount = 4; private final int mColumnCount = 4;
private RowScale[] mServiceTargetScale;
private final Interpolator mInterpolator;
private int mAnimationCount = 0; private int mAnimationCount = 0;
public ChooserRowAdapter(ChooserListAdapter wrappedAdapter) { public ChooserRowAdapter(ChooserListAdapter wrappedAdapter) {
mChooserListAdapter = wrappedAdapter; mChooserListAdapter = wrappedAdapter;
mLayoutInflater = LayoutInflater.from(ChooserActivity.this); mLayoutInflater = LayoutInflater.from(ChooserActivity.this);
mInterpolator = AnimationUtils.loadInterpolator(ChooserActivity.this,
android.R.interpolator.decelerate_quint);
wrappedAdapter.registerDataSetObserver(new DataSetObserver() { wrappedAdapter.registerDataSetObserver(new DataSetObserver() {
@Override @Override
public void onChanged() { public void onChanged() {
super.onChanged(); super.onChanged();
final int rcount = getServiceTargetRowCount();
if (mServiceTargetScale == null
|| mServiceTargetScale.length != rcount) {
RowScale[] old = mServiceTargetScale;
int oldRCount = old != null ? old.length : 0;
mServiceTargetScale = new RowScale[rcount];
if (old != null && rcount > 0) {
System.arraycopy(old, 0, mServiceTargetScale, 0,
Math.min(old.length, rcount));
}
for (int i = rcount; i < oldRCount; i++) {
old[i].cancelAnimation();
}
for (int i = oldRCount; i < rcount; i++) {
final RowScale rs = new RowScale(ChooserRowAdapter.this, 0.f, 1.f)
.setInterpolator(mInterpolator);
mServiceTargetScale[i] = rs;
}
// Start the animations in a separate loop.
// The process of starting animations will result in
// binding views to set up initial values, and we must
// have ALL of the new RowScale objects created above before
// we get started.
for (int i = oldRCount; i < rcount; i++) {
mServiceTargetScale[i].startAnimation();
}
}
notifyDataSetChanged(); notifyDataSetChanged();
} }
...@@ -1313,39 +1211,10 @@ public class ChooserActivity extends ResolverActivity { ...@@ -1313,39 +1211,10 @@ public class ChooserActivity extends ResolverActivity {
public void onInvalidated() { public void onInvalidated() {
super.onInvalidated(); super.onInvalidated();
notifyDataSetInvalidated(); notifyDataSetInvalidated();
if (mServiceTargetScale != null) {
for (RowScale rs : mServiceTargetScale) {
rs.cancelAnimation();
}
}
} }
}); });
} }
private float getRowScale(int rowPosition) {
final int start = getCallerTargetRowCount();
final int end = start + getServiceTargetRowCount();
if (rowPosition >= start && rowPosition < end) {
return mServiceTargetScale[rowPosition - start].get();
}
return 1.f;
}
public void onAnimationStart() {
final boolean lock = mAnimationCount == 0;
mAnimationCount++;
if (lock) {
mResolverDrawerLayout.setDismissLocked(true);
}
}
public void onAnimationEnd() {
mAnimationCount--;
if (mAnimationCount == 0) {
mResolverDrawerLayout.setDismissLocked(false);
}
}
@Override @Override
public int getCount() { public int getCount() {
return (int) ( return (int) (
...@@ -1360,9 +1229,9 @@ public class ChooserActivity extends ResolverActivity { ...@@ -1360,9 +1229,9 @@ public class ChooserActivity extends ResolverActivity {
(float) mChooserListAdapter.getCallerTargetCount() / mColumnCount); (float) mChooserListAdapter.getCallerTargetCount() / mColumnCount);
} }
// There can be at most one row of service targets.
public int getServiceTargetRowCount() { public int getServiceTargetRowCount() {
return (int) Math.ceil( return (int) mChooserListAdapter.getServiceTargetCount() == 0 ? 0 : 1;
(float) mChooserListAdapter.getServiceTargetCount() / mColumnCount);
} }
@Override @Override
...@@ -1485,8 +1354,7 @@ public class ChooserActivity extends ResolverActivity { ...@@ -1485,8 +1354,7 @@ public class ChooserActivity extends ResolverActivity {
} }
final int oldHeight = holder.row.getLayoutParams().height; final int oldHeight = holder.row.getLayoutParams().height;
holder.row.getLayoutParams().height = Math.max(1, holder.row.getLayoutParams().height = Math.max(1, holder.measuredRowHeight);
(int) (holder.measuredRowHeight * getRowScale(rowPosition)));
if (holder.row.getLayoutParams().height != oldHeight) { if (holder.row.getLayoutParams().height != oldHeight) {
holder.row.requestLayout(); holder.row.requestLayout();
} }
...@@ -1728,7 +1596,7 @@ public class ChooserActivity extends ResolverActivity { ...@@ -1728,7 +1596,7 @@ public class ChooserActivity extends ResolverActivity {
final View v = mChooserRowAdapter.getView(pos, mCachedView, mListView); final View v = mChooserRowAdapter.getView(pos, mCachedView, mListView);
int height = ((RowViewHolder) (v.getTag())).measuredRowHeight; int height = ((RowViewHolder) (v.getTag())).measuredRowHeight;
offset += (int) (height * mChooserRowAdapter.getRowScale(pos)); offset += (int) (height);
if (vt >= 0) { if (vt >= 0) {
mCachedViewType = vt; mCachedViewType = vt;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment