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

Commit bda0b769 authored by Song Hu's avatar Song Hu
Browse files

Pass shared text content from ChooserActivity to AppPredictionService

Bug: 232426274
Test: manual test on local phone
Test: atest
Change-Id: Idc1d2f8efddab45cfaacd4a78cd745b9273b2719
parent 6474aed2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public class ChooserActivity extends ResolverActivity implements
    private static final String SHORTCUT_TARGET = "shortcut_target";
    private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20;
    public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter";
    private static final String SHARED_TEXT_KEY = "shared_text";

    private static final String PLURALS_COUNT = "count";
    private static final String PLURALS_FILE_NAME = "file_name";
@@ -2194,6 +2195,7 @@ public class ChooserActivity extends ResolverActivity implements
        final IntentFilter filter = getTargetIntentFilter();
        Bundle extras = new Bundle();
        extras.putParcelable(APP_PREDICTION_INTENT_FILTER_KEY, filter);
        populateTextContent(extras);
        AppPredictionContext appPredictionContext = new AppPredictionContext.Builder(contextAsUser)
            .setUiSurface(APP_PREDICTION_SHARE_UI_SURFACE)
            .setPredictedTargetCount(APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT)
@@ -2212,6 +2214,12 @@ public class ChooserActivity extends ResolverActivity implements
        return appPredictionSession;
    }

    private void populateTextContent(Bundle extras) {
        final Intent intent = getTargetIntent();
        String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
        extras.putString(SHARED_TEXT_KEY, sharedText);
    }

    /**
     * This will return an app predictor if it is enabled for direct share sorting
     * and if one exists. Otherwise, it returns null.