summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2023-04-13 01:25:04 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-04-13 01:25:04 +0000
commit96cd17b99e572f1aaa2b3ecf2c85ca202e829732 (patch)
treef6474c59deddef690866e4257600f6895ac7b06f /java/src
parent90145cf580d98fdca9b09c3a3f332e6830a23841 (diff)
parent41d6899b07b8429297014844d30c3f079c65ba2a (diff)
Merge "Delete unused direct share expansion code" into udc-dev am: 41d6899b07
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/IntentResolver/+/22477022 Change-Id: Ice0b12b4c7acd7b9537f6b0f07979b240cc34d44 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/intentresolver/ChooserActivity.java91
-rw-r--r--java/src/com/android/intentresolver/grid/ChooserGridAdapter.java71
-rw-r--r--java/src/com/android/intentresolver/grid/DirectShareViewHolder.java87
3 files changed, 15 insertions, 234 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java
index dc9ba5ee..75ee0648 100644
--- a/java/src/com/android/intentresolver/ChooserActivity.java
+++ b/java/src/com/android/intentresolver/ChooserActivity.java
@@ -57,7 +57,6 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
-import android.provider.DeviceConfig;
import android.service.chooser.ChooserTarget;
import android.util.Log;
import android.util.Slog;
@@ -88,7 +87,6 @@ import com.android.intentresolver.contentpreview.HeadlineGeneratorImpl;
import com.android.intentresolver.flags.FeatureFlagRepository;
import com.android.intentresolver.flags.FeatureFlagRepositoryFactory;
import com.android.intentresolver.grid.ChooserGridAdapter;
-import com.android.intentresolver.grid.DirectShareViewHolder;
import com.android.intentresolver.model.AbstractResolverComparator;
import com.android.intentresolver.model.AppPredictionServiceResolverComparator;
import com.android.intentresolver.model.ResolverRankerServiceResolverComparator;
@@ -96,7 +94,6 @@ import com.android.intentresolver.shortcuts.AppPredictorFactory;
import com.android.intentresolver.shortcuts.ShortcutLoader;
import com.android.intentresolver.widget.ResolverDrawerLayout;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.content.PackageMonitor;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -141,19 +138,11 @@ public class ChooserActivity extends ResolverActivity implements
private static final String PREF_NUM_SHEET_EXPANSIONS = "pref_num_sheet_expansions";
- private static final String CHIP_LABEL_METADATA_KEY = "android.service.chooser.chip_label";
- private static final String CHIP_ICON_METADATA_KEY = "android.service.chooser.chip_icon";
-
private static final boolean DEBUG = true;
public static final String LAUNCH_LOCATION_DIRECT_SHARE = "direct_share";
private static final String SHORTCUT_TARGET = "shortcut_target";
- private static final String PLURALS_COUNT = "count";
- private static final String PLURALS_FILE_NAME = "file_name";
-
- private static final String IMAGE_EDITOR_SHARED_ELEMENT = "screenshot_preview_image";
-
// TODO: these data structures are for one-time use in shuttling data from where they're
// populated in `ShortcutToChooserTargetConverter` to where they're consumed in
// `ShortcutSelectionLogic` which packs the appropriate elements into the final `TargetInfo`.
@@ -180,18 +169,6 @@ public class ChooserActivity extends ResolverActivity implements
@Retention(RetentionPolicy.SOURCE)
public @interface ShareTargetType {}
- public static final float DIRECT_SHARE_EXPANSION_RATE = 0.78f;
-
- private static final int DEFAULT_SALT_EXPIRATION_DAYS = 7;
- private final int mMaxHashSaltDays = DeviceConfig.getInt(DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.HASH_SALT_MAX_DAYS,
- DEFAULT_SALT_EXPIRATION_DAYS);
-
- private static final int URI_PERMISSION_INTENT_FLAGS = Intent.FLAG_GRANT_READ_URI_PERMISSION
- | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
- | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
- | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION;
-
private ChooserIntegratedDeviceComponents mIntegratedDeviceComponents;
/* TODO: this is `nullable` because we have to defer the assignment til onCreate(). We make the
@@ -329,11 +306,6 @@ public class ChooserActivity extends ResolverActivity implements
if (mResolverDrawerLayout != null) {
mResolverDrawerLayout.addOnLayoutChangeListener(this::handleLayoutChange);
- // expand/shrink direct share 4 -> 8 viewgroup
- if (mChooserRequest.isSendActionTarget()) {
- mResolverDrawerLayout.setOnScrollChangeListener(this::handleScroll);
- }
-
mResolverDrawerLayout.setOnCollapsedChangedListener(
new ResolverDrawerLayout.OnCollapsedChangedListener() {
@@ -1240,34 +1212,6 @@ public class ChooserActivity extends ResolverActivity implements
mProfileView.setOnClickListener(ChooserActivity.this::onProfileClick);
ChooserActivity.this.updateProfileViewButton();
}
-
- @Override
- public int getValidTargetCount() {
- return mChooserMultiProfilePagerAdapter
- .getActiveListAdapter()
- .getSelectableServiceTargetCount();
- }
-
- @Override
- public void updateDirectShareExpansion(DirectShareViewHolder directShareGroup) {
- RecyclerView activeAdapterView =
- mChooserMultiProfilePagerAdapter.getActiveAdapterView();
- if (mResolverDrawerLayout.isCollapsed()) {
- directShareGroup.collapse(activeAdapterView);
- } else {
- directShareGroup.expand(activeAdapterView);
- }
- }
-
- @Override
- public void handleScrollToExpandDirectShare(
- DirectShareViewHolder directShareGroup, int y, int oldy) {
- directShareGroup.handleScroll(
- mChooserMultiProfilePagerAdapter.getActiveAdapterView(),
- y,
- oldy,
- mMaxTargetsPerRow);
- }
},
chooserListAdapter,
shouldShowContentPreview(),
@@ -1381,12 +1325,6 @@ public class ChooserActivity extends ResolverActivity implements
});
}
- private void handleScroll(View view, int x, int y, int oldx, int oldy) {
- if (mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() != null) {
- mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().handleScroll(view, y, oldy);
- }
- }
-
/*
* Need to dynamically adjust how many icons can fit per row before we add them,
* which also means setting the correct offset to initially show the content
@@ -1455,9 +1393,7 @@ public class ChooserActivity extends ResolverActivity implements
private int calculateDrawerOffset(
int top, int bottom, RecyclerView recyclerView, ChooserGridAdapter gridAdapter) {
- final int bottomInset = mSystemWindowInsets != null
- ? mSystemWindowInsets.bottom : 0;
- int offset = bottomInset;
+ int offset = mSystemWindowInsets != null ? mSystemWindowInsets.bottom : 0;
int rowsToShow = gridAdapter.getSystemRowCount()
+ gridAdapter.getProfileRowCount()
+ gridAdapter.getServiceTargetRowCount()
@@ -1487,7 +1423,6 @@ public class ChooserActivity extends ResolverActivity implements
}
if (recyclerView.getVisibility() == View.VISIBLE) {
- int directShareHeight = 0;
rowsToShow = Math.min(4, rowsToShow);
boolean shouldShowExtraRow = shouldShowExtraRow(rowsToShow);
mLastNumberOfChildren = recyclerView.getChildCount();
@@ -1503,29 +1438,8 @@ public class ChooserActivity extends ResolverActivity implements
if (shouldShowExtraRow) {
offset += height;
}
-
- if (gridAdapter.getTargetType(
- recyclerView.getChildAdapterPosition(child))
- == ChooserListAdapter.TARGET_SERVICE) {
- directShareHeight = height;
- }
rowsToShow--;
}
-
- boolean isPortrait = getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_PORTRAIT;
- boolean isExpandable = isPortrait && !isInMultiWindowMode()
- && gridAdapter.canExpandDirectShare();
- if (directShareHeight != 0 && shouldShowContentPreview() && isExpandable) {
- // make sure to leave room for direct share 4->8 expansion, if enabled
- int requiredExpansionHeight =
- (int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE);
- int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0;
- int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight()
- - requiredExpansionHeight - topInset - bottomInset;
-
- offset = Math.min(offset, minHeight);
- }
} else {
ViewGroup currentEmptyStateView = getActiveEmptyStateView();
if (currentEmptyStateView.getVisibility() == View.VISIBLE) {
@@ -1825,9 +1739,6 @@ public class ChooserActivity extends ResolverActivity implements
@Override
protected void onProfileTabSelected() {
- ChooserGridAdapter currentRootAdapter =
- mChooserMultiProfilePagerAdapter.getCurrentRootAdapter();
- currentRootAdapter.updateDirectShareExpansion();
// This fixes an edge case where after performing a variety of gestures, vertical scrolling
// ends up disabled. That's because at some point the old tab's vertical scrolling is
// disabled and the new tab's is enabled. For context, see b/159997845
diff --git a/java/src/com/android/intentresolver/grid/ChooserGridAdapter.java b/java/src/com/android/intentresolver/grid/ChooserGridAdapter.java
index 96f8c4d1..e6f70d4f 100644
--- a/java/src/com/android/intentresolver/grid/ChooserGridAdapter.java
+++ b/java/src/com/android/intentresolver/grid/ChooserGridAdapter.java
@@ -89,26 +89,6 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
* behaviors on this view.
*/
void updateProfileViewButton(View newButtonFromProfileRow);
-
- /**
- * @return the number of "valid" targets in the active list adapter.
- * TODO: define "valid."
- */
- int getValidTargetCount();
-
- /**
- * Request that the client update our {@code directShareGroup} to match their desired
- * state for the "expansion" UI.
- */
- void updateDirectShareExpansion(DirectShareViewHolder directShareGroup);
-
- /**
- * Request that the client handle a scroll event that should be taken as expanding the
- * provided {@code directShareGroup}. Note that this currently never happens due to a
- * hard-coded condition in {@link #canExpandDirectShare()}.
- */
- void handleScrollToExpandDirectShare(
- DirectShareViewHolder directShareGroup, int y, int oldy);
}
private static final int VIEW_TYPE_DIRECT_SHARE = 0;
@@ -131,7 +111,6 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
private final int mChooserRowTextOptionTranslatePixelSize;
private final boolean mShowAzLabelIfPoss;
- private DirectShareViewHolder mDirectShareViewHolder;
private int mChooserTargetWidth = 0;
private int mFooterHeight = 0;
@@ -190,8 +169,7 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
}
// Limit width to the maximum width of the chooser activity
- int maxWidth = mChooserWidthPixels;
- width = Math.min(maxWidth, width);
+ width = Math.min(mChooserWidthPixels, width);
int newWidth = width / mMaxTargetsPerRow;
if (newWidth != mChooserTargetWidth) {
@@ -270,15 +248,13 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
@Override
public int getItemCount() {
- return (int) (
- getSystemRowCount()
- + getProfileRowCount()
- + getServiceTargetRowCount()
- + getCallerAndRankedTargetRowCount()
- + getAzLabelRowCount()
- + mChooserListAdapter.getAlphaTargetCount()
- + getFooterRowCount()
- );
+ return getSystemRowCount()
+ + getProfileRowCount()
+ + getServiceTargetRowCount()
+ + getCallerAndRankedTargetRowCount()
+ + getAzLabelRowCount()
+ + mChooserListAdapter.getAlphaTargetCount()
+ + getFooterRowCount();
}
@Override
@@ -453,12 +429,11 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
parentGroup.addView(row1);
parentGroup.addView(row2);
- mDirectShareViewHolder = new DirectShareViewHolder(parentGroup,
- Lists.newArrayList(row1, row2), mMaxTargetsPerRow, viewType,
- mChooserActivityDelegate::getValidTargetCount);
- loadViewsIntoGroup(mDirectShareViewHolder);
+ DirectShareViewHolder directShareViewHolder = new DirectShareViewHolder(parentGroup,
+ Lists.newArrayList(row1, row2), mMaxTargetsPerRow, viewType);
+ loadViewsIntoGroup(directShareViewHolder);
- return mDirectShareViewHolder;
+ return directShareViewHolder;
} else {
ViewGroup row = (ViewGroup) mLayoutInflater.inflate(
R.layout.chooser_row, parent, false);
@@ -572,21 +547,6 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
return callerAndRankedCount + serviceCount + position;
}
- public void handleScroll(View v, int y, int oldy) {
- boolean canExpandDirectShare = canExpandDirectShare();
- if (mDirectShareViewHolder != null && canExpandDirectShare) {
- mChooserActivityDelegate.handleScrollToExpandDirectShare(
- mDirectShareViewHolder, y, oldy);
- }
- }
-
- /** Only expand direct share area if there is a minimum number of targets. */
- public boolean canExpandDirectShare() {
- // Do not enable until we have confirmed more apps are using sharing shortcuts
- // Check git history for enablement logic
- return false;
- }
-
public ChooserListAdapter getListAdapter() {
return mChooserListAdapter;
}
@@ -594,11 +554,4 @@ public final class ChooserGridAdapter extends RecyclerView.Adapter<RecyclerView.
public boolean shouldCellSpan(int position) {
return getItemViewType(position) == VIEW_TYPE_NORMAL;
}
-
- public void updateDirectShareExpansion() {
- if (mDirectShareViewHolder == null || !canExpandDirectShare()) {
- return;
- }
- mChooserActivityDelegate.updateDirectShareExpansion(mDirectShareViewHolder);
- }
}
diff --git a/java/src/com/android/intentresolver/grid/DirectShareViewHolder.java b/java/src/com/android/intentresolver/grid/DirectShareViewHolder.java
index 316c9f07..ad78c719 100644
--- a/java/src/com/android/intentresolver/grid/DirectShareViewHolder.java
+++ b/java/src/com/android/intentresolver/grid/DirectShareViewHolder.java
@@ -25,35 +25,25 @@ import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.android.intentresolver.ChooserActivity;
-
import java.util.Arrays;
import java.util.List;
-import java.util.function.Supplier;
/** Holder for direct share targets in the {@link ChooserGridAdapter}. */
public class DirectShareViewHolder extends ItemGroupViewHolder {
private final ViewGroup mParent;
private final List<ViewGroup> mRows;
- private int mCellCountPerRow;
+ private final int mCellCountPerRow;
- private boolean mHideDirectShareExpansion = false;
private int mDirectShareMinHeight = 0;
private int mDirectShareCurrHeight = 0;
- private int mDirectShareMaxHeight = 0;
private final boolean[] mCellVisibility;
- private final Supplier<Integer> mDeferredTargetCountSupplier;
-
public DirectShareViewHolder(
ViewGroup parent,
List<ViewGroup> rows,
int cellCountPerRow,
- int viewType,
- Supplier<Integer> deferredTargetCountSupplier) {
+ int viewType) {
super(rows.size() * cellCountPerRow, parent, viewType);
this.mParent = parent;
@@ -61,7 +51,6 @@ public class DirectShareViewHolder extends ItemGroupViewHolder {
this.mCellCountPerRow = cellCountPerRow;
this.mCellVisibility = new boolean[rows.size() * cellCountPerRow];
Arrays.fill(mCellVisibility, true);
- this.mDeferredTargetCountSupplier = deferredTargetCountSupplier;
}
public ViewGroup addView(int index, View v) {
@@ -92,7 +81,6 @@ public class DirectShareViewHolder extends ItemGroupViewHolder {
mDirectShareMinHeight = getRow(0).getMeasuredHeight();
mDirectShareCurrHeight = (mDirectShareCurrHeight > 0)
? mDirectShareCurrHeight : mDirectShareMinHeight;
- mDirectShareMaxHeight = 2 * mDirectShareMinHeight;
}
public int getMeasuredRowHeight() {
@@ -123,75 +111,4 @@ public class DirectShareViewHolder extends ItemGroupViewHolder {
fadeAnim.start();
}
}
-
- public void handleScroll(RecyclerView view, int y, int oldy, int maxTargetsPerRow) {
- // only exit early if fully collapsed, otherwise onListRebuilt() with shifting
- // targets can lock us into an expanded mode
- boolean notExpanded = mDirectShareCurrHeight == mDirectShareMinHeight;
- if (notExpanded) {
- if (mHideDirectShareExpansion) {
- return;
- }
-
- // only expand if we have more than maxTargetsPerRow, and delay that decision
- // until they start to scroll
- final int validTargets = this.mDeferredTargetCountSupplier.get();
- if (validTargets <= maxTargetsPerRow) {
- mHideDirectShareExpansion = true;
- return;
- }
- }
-
- int yDiff = (int) ((oldy - y) * ChooserActivity.DIRECT_SHARE_EXPANSION_RATE);
-
- int prevHeight = mDirectShareCurrHeight;
- int newHeight = Math.min(prevHeight + yDiff, mDirectShareMaxHeight);
- newHeight = Math.max(newHeight, mDirectShareMinHeight);
- yDiff = newHeight - prevHeight;
-
- updateDirectShareRowHeight(view, yDiff, newHeight);
- }
-
- public void expand(RecyclerView view) {
- updateDirectShareRowHeight(
- view, mDirectShareMaxHeight - mDirectShareCurrHeight, mDirectShareMaxHeight);
- }
-
- public void collapse(RecyclerView view) {
- updateDirectShareRowHeight(
- view, mDirectShareMinHeight - mDirectShareCurrHeight, mDirectShareMinHeight);
- }
-
- private void updateDirectShareRowHeight(RecyclerView view, int yDiff, int newHeight) {
- if (view == null || view.getChildCount() == 0 || yDiff == 0) {
- return;
- }
-
- // locate the item to expand, and offset the rows below that one
- boolean foundExpansion = false;
- for (int i = 0; i < view.getChildCount(); i++) {
- View child = view.getChildAt(i);
-
- if (foundExpansion) {
- child.offsetTopAndBottom(yDiff);
- } else {
- if (child.getTag() != null && child.getTag() instanceof DirectShareViewHolder) {
- int widthSpec = MeasureSpec.makeMeasureSpec(child.getWidth(),
- MeasureSpec.EXACTLY);
- int heightSpec = MeasureSpec.makeMeasureSpec(newHeight,
- MeasureSpec.EXACTLY);
- child.measure(widthSpec, heightSpec);
- child.getLayoutParams().height = child.getMeasuredHeight();
- child.layout(child.getLeft(), child.getTop(), child.getRight(),
- child.getTop() + child.getMeasuredHeight());
-
- foundExpansion = true;
- }
- }
- }
-
- if (foundExpansion) {
- mDirectShareCurrHeight = newHeight;
- }
- }
}