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

Commit 268d43ef authored by Yuliya Kamatkova's avatar Yuliya Kamatkova Committed by Android (Google) Code Review
Browse files

Merge "Pass Activity LocusContext to the Content Capture."

parents ac21f749 b5d87a86
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillManager.AutofillClient;
import android.view.autofill.AutofillPopupWindow;
import android.view.autofill.IAutofillWindowPresenter;
import android.view.contentcapture.ContentCaptureContext;
import android.view.contentcapture.ContentCaptureManager;
import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient;
import android.widget.AdapterView;
@@ -1056,7 +1057,10 @@ public class Activity extends ContextThemeWrapper
        } catch (RemoteException re) {
            re.rethrowFromSystemServer();
        }
        // TODO(b/147750355): Pass locusId and bundle to the Content Capture.
        // If locusId is not null pass it to the Content Capture.
        if (locusId != null) {
            setLocusContextToContentCapture(locusId, bundle);
        }
    }

    /** Return the application that owns this activity. */
@@ -1209,6 +1213,19 @@ public class Activity extends ContextThemeWrapper
        }
    }

    private void setLocusContextToContentCapture(LocusId locusId, @Nullable Bundle bundle) {
        final ContentCaptureManager cm = getContentCaptureManager();
        if (cm == null) return;

        ContentCaptureContext.Builder contentCaptureContextBuilder =
                new ContentCaptureContext.Builder(locusId);
        if (bundle != null) {
            contentCaptureContextBuilder.setExtras(bundle);
        }
        cm.getMainContentCaptureSession().setContentCaptureContext(
                contentCaptureContextBuilder.build());
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);