[Search] [People] Pass intent to People view instead of URI.

Tested:
On Phone

Bug: 169294622

Change-Id: I4e379a80a256e018761af2925e640745456faeec
This commit is contained in:
jayaprakashs 2020-09-23 22:46:36 -07:00 committed by Jayaprakash Sundararaj
parent f01064953b
commit b7487f867c
1 changed files with 19 additions and 30 deletions

View File

@ -15,9 +15,6 @@
*/
package com.android.launcher3.views;
import static android.content.Intent.URI_ALLOW_UNSAFE;
import static android.content.Intent.URI_ANDROID_APP_SCHEME;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
@ -28,7 +25,6 @@ import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
@ -50,7 +46,6 @@ import com.android.systemui.plugins.AllAppsSearchPlugin;
import com.android.systemui.plugins.shared.SearchTarget;
import com.android.systemui.plugins.shared.SearchTargetEvent;
import java.net.URISyntaxException;
import java.util.ArrayList;
/**
@ -66,7 +61,7 @@ public class SearchResultPeopleView extends LinearLayout implements
private TextView mTitleView;
private ImageButton[] mProviderButtons = new ImageButton[3];
private AllAppsSearchPlugin mPlugin;
private Uri mContactUri;
private Intent mIntent;
private final Object[] mTargetInfo = createTargetInfo();
public SearchResultPeopleView(Context context) {
@ -109,7 +104,7 @@ public class SearchResultPeopleView extends LinearLayout implements
Bundle payload = adapterItemWithPayload.getPayload();
mPlugin = adapterItemWithPayload.getPlugin();
mTitleView.setText(payload.getString("title"));
mContactUri = payload.getParcelable("contact_uri");
mIntent = payload.getParcelable("intent");
Bitmap icon = payload.getParcelable("icon");
if (icon != null) {
RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), icon);
@ -125,10 +120,8 @@ public class SearchResultPeopleView extends LinearLayout implements
for (int i = 0; i < mProviderButtons.length; i++) {
ImageButton button = mProviderButtons[i];
if (providers != null && i < providers.size()) {
try {
Bundle provider = providers.get(i);
Intent intent = Intent.parseUri(provider.getString("intent_uri_str"),
URI_ANDROID_APP_SCHEME | URI_ALLOW_UNSAFE);
Intent intent = provider.getParcelable("intent");
setupProviderButton(button, provider, intent, adapterItemWithPayload);
String pkg = provider.getString("package_name");
UI_HELPER_EXECUTOR.post(() -> {
@ -141,9 +134,6 @@ public class SearchResultPeopleView extends LinearLayout implements
}
});
} catch (URISyntaxException ex) {
button.setVisibility(GONE);
}
} else {
button.setVisibility(GONE);
}
@ -165,7 +155,7 @@ public class SearchResultPeopleView extends LinearLayout implements
SearchTarget.ItemType.PEOPLE,
SearchTargetEvent.CHILD_SELECT);
searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri);
searchTargetEvent.bundle.putParcelable("intent", mIntent);
searchTargetEvent.bundle.putBundle("provider", provider);
if (mPlugin != null) {
mPlugin.notifySearchTargetEvent(searchTargetEvent);
@ -175,14 +165,13 @@ public class SearchResultPeopleView extends LinearLayout implements
private void handleSelection(int eventType) {
if (mContactUri != null) {
if (mIntent != null) {
Launcher launcher = Launcher.getLauncher(getContext());
launcher.startActivitySafely(this, new Intent(Intent.ACTION_VIEW, mContactUri).setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK), null);
launcher.startActivitySafely(this, mIntent, null);
SearchTargetEvent searchTargetEvent = getSearchTargetEvent(SearchTarget.ItemType.PEOPLE,
eventType);
searchTargetEvent.bundle = new Bundle();
searchTargetEvent.bundle.putParcelable("contact_uri", mContactUri);
searchTargetEvent.bundle.putParcelable("intent", mIntent);
if (mPlugin != null) {
mPlugin.notifySearchTargetEvent(searchTargetEvent);
}