Loading packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,10 @@ This name is in the ComponentName flattened format (package/class) --> <string name="config_screenshotEditor" translatable="false"></string> <!-- Remote copy default activity. Must handle REMOTE_COPY_ACTION intents. This name is in the ComponentName flattened format (package/class) --> <string name="config_remoteCopyPackage" translatable="false"></string> <!-- On debuggable builds, alert the user if SystemUI PSS goes over this number (in kb) --> <integer name="watch_heap_limit">256000</integer> Loading packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java +22 −18 Original line number Diff line number Diff line Loading @@ -221,17 +221,6 @@ public class ClipboardOverlayController { mRemoteCopyChip.setIcon( Icon.createWithResource(mContext, R.drawable.ic_baseline_devices_24), true); // Only show remote copy if it's available. PackageManager packageManager = mContext.getPackageManager(); if (packageManager.resolveActivity(getRemoteCopyIntent(), 0) != null) { mRemoteCopyChip.setOnClickListener((v) -> { showNearby(); }); mRemoteCopyChip.setAlpha(1f); } else { mRemoteCopyChip.setVisibility(View.GONE); } attachWindow(); withWindowAttached(() -> { mWindow.setContentView(mContainer); Loading Loading @@ -294,6 +283,20 @@ public class ClipboardOverlayController { showTextPreview( mContext.getResources().getString(R.string.clipboard_overlay_text_copied)); } Intent remoteCopyIntent = getRemoteCopyIntent(clipData); // Only show remote copy if it's available. PackageManager packageManager = mContext.getPackageManager(); if (remoteCopyIntent != null && packageManager.resolveActivity( remoteCopyIntent, PackageManager.ResolveInfoFlags.of(0)) != null) { mRemoteCopyChip.setOnClickListener((v) -> { mUiEventLogger.log(CLIPBOARD_OVERLAY_REMOTE_COPY_TAPPED); mContext.startActivity(remoteCopyIntent); animateOut(); }); mRemoteCopyChip.setAlpha(1f); } else { mRemoteCopyChip.setVisibility(View.GONE); } mTimeoutHandler.resetTimeout(); } Loading Loading @@ -397,12 +400,6 @@ public class ClipboardOverlayController { animateOut(); } private void showNearby() { mUiEventLogger.log(CLIPBOARD_OVERLAY_REMOTE_COPY_TAPPED); mContext.startActivity(getRemoteCopyIntent()); animateOut(); } private void showTextPreview(CharSequence text) { mTextPreview.setVisibility(View.VISIBLE); mImagePreview.setVisibility(View.GONE); Loading Loading @@ -442,8 +439,15 @@ public class ClipboardOverlayController { mImagePreview.setOnClickListener(listener); } private Intent getRemoteCopyIntent() { private Intent getRemoteCopyIntent(ClipData clipData) { String remoteCopyPackage = mContext.getString(R.string.config_remoteCopyPackage); if (TextUtils.isEmpty(remoteCopyPackage)) { return null; } Intent nearbyIntent = new Intent(REMOTE_COPY_ACTION); nearbyIntent.setComponent(ComponentName.unflattenFromString(remoteCopyPackage)); nearbyIntent.setClipData(clipData); nearbyIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return nearbyIntent; } Loading Loading
packages/SystemUI/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,10 @@ This name is in the ComponentName flattened format (package/class) --> <string name="config_screenshotEditor" translatable="false"></string> <!-- Remote copy default activity. Must handle REMOTE_COPY_ACTION intents. This name is in the ComponentName flattened format (package/class) --> <string name="config_remoteCopyPackage" translatable="false"></string> <!-- On debuggable builds, alert the user if SystemUI PSS goes over this number (in kb) --> <integer name="watch_heap_limit">256000</integer> Loading
packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java +22 −18 Original line number Diff line number Diff line Loading @@ -221,17 +221,6 @@ public class ClipboardOverlayController { mRemoteCopyChip.setIcon( Icon.createWithResource(mContext, R.drawable.ic_baseline_devices_24), true); // Only show remote copy if it's available. PackageManager packageManager = mContext.getPackageManager(); if (packageManager.resolveActivity(getRemoteCopyIntent(), 0) != null) { mRemoteCopyChip.setOnClickListener((v) -> { showNearby(); }); mRemoteCopyChip.setAlpha(1f); } else { mRemoteCopyChip.setVisibility(View.GONE); } attachWindow(); withWindowAttached(() -> { mWindow.setContentView(mContainer); Loading Loading @@ -294,6 +283,20 @@ public class ClipboardOverlayController { showTextPreview( mContext.getResources().getString(R.string.clipboard_overlay_text_copied)); } Intent remoteCopyIntent = getRemoteCopyIntent(clipData); // Only show remote copy if it's available. PackageManager packageManager = mContext.getPackageManager(); if (remoteCopyIntent != null && packageManager.resolveActivity( remoteCopyIntent, PackageManager.ResolveInfoFlags.of(0)) != null) { mRemoteCopyChip.setOnClickListener((v) -> { mUiEventLogger.log(CLIPBOARD_OVERLAY_REMOTE_COPY_TAPPED); mContext.startActivity(remoteCopyIntent); animateOut(); }); mRemoteCopyChip.setAlpha(1f); } else { mRemoteCopyChip.setVisibility(View.GONE); } mTimeoutHandler.resetTimeout(); } Loading Loading @@ -397,12 +400,6 @@ public class ClipboardOverlayController { animateOut(); } private void showNearby() { mUiEventLogger.log(CLIPBOARD_OVERLAY_REMOTE_COPY_TAPPED); mContext.startActivity(getRemoteCopyIntent()); animateOut(); } private void showTextPreview(CharSequence text) { mTextPreview.setVisibility(View.VISIBLE); mImagePreview.setVisibility(View.GONE); Loading Loading @@ -442,8 +439,15 @@ public class ClipboardOverlayController { mImagePreview.setOnClickListener(listener); } private Intent getRemoteCopyIntent() { private Intent getRemoteCopyIntent(ClipData clipData) { String remoteCopyPackage = mContext.getString(R.string.config_remoteCopyPackage); if (TextUtils.isEmpty(remoteCopyPackage)) { return null; } Intent nearbyIntent = new Intent(REMOTE_COPY_ACTION); nearbyIntent.setComponent(ComponentName.unflattenFromString(remoteCopyPackage)); nearbyIntent.setClipData(clipData); nearbyIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return nearbyIntent; } Loading