From 78505e91f7e054444030aec55110893b4fc62500 Mon Sep 17 00:00:00 2001 From: Edwin Wu Date: Wed, 10 Apr 2024 19:17:26 -0700 Subject: [PATCH] Add the privacy manifests for swift NC-SDK. PiperOrigin-RevId: 623676227 --- internal/platform/implementation/apple/BUILD | 22 ++--- sharing/android/README.md | 82 +------------------ .../google/nearby/sharedemo/MainActivity.kt | 12 --- sharing/android/example/build.gradle.kts | 2 +- 4 files changed, 16 insertions(+), 102 deletions(-) diff --git a/internal/platform/implementation/apple/BUILD b/internal/platform/implementation/apple/BUILD index 5b0914ce..4ab088e7 100644 --- a/internal/platform/implementation/apple/BUILD +++ b/internal/platform/implementation/apple/BUILD @@ -50,23 +50,25 @@ objc_library( ":Platform_cc", ":Shared", ":ble_v2", - "//internal/platform:base", - "//internal/platform/implementation:comm", - "//internal/platform/implementation:platform", - "//internal/platform/implementation:types", - "//internal/platform/implementation/apple/Mediums", - "//internal/platform/implementation/shared:file", - "//third_party/apple_frameworks:CoreBluetooth", - "//third_party/apple_frameworks:Foundation", - "//third_party/apple_frameworks:Network", - "//third_party/objective_c/google_toolbox_for_mac:GTM_Logger", + # Required Reason API File: third_party/nearby/internal/platform/implementation/apple/preferences_manager.mm + "//releasetools/apple/privacy/privacymanifests/requiredreasonsapi:user_defaults-user_defaults-read_write_app_data_ca92_1", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", "@com_google_absl//absl/types:span", + "//third_party/apple_frameworks:CoreBluetooth", + "//third_party/apple_frameworks:Foundation", + "//third_party/apple_frameworks:Network", "@nlohmann_json//:json", + "//internal/platform:base", + "//internal/platform/implementation:comm", + "//internal/platform/implementation:platform", + "//internal/platform/implementation:types", + "//internal/platform/implementation/apple/Mediums", + "//internal/platform/implementation/shared:file", + "//third_party/objective_c/google_toolbox_for_mac:GTM_Logger", ] + select({ "@platforms//os:platform_ios": [ "//third_party/apple_frameworks:UIKit", diff --git a/sharing/android/README.md b/sharing/android/README.md index af2a4629..a9e26abb 100644 --- a/sharing/android/README.md +++ b/sharing/android/README.md @@ -1,88 +1,12 @@ # Nearby Sharing Android API -## Checking if Quick Share (Google) is supported on your device. -Quick Share by Google has its own UI, and to use the below launch intents, the availability of these intents needs to be checked first. -This can be done by calling `PackageManager#queryIntentActivities()` with the intent required. A good rule of thumb to check if Quick Share is enabled is to run this check with the intent ```com.google.android.gms.SHARE_NEARBY```. - -Example code: -```kotlin -val shareIntent = Intent("com.google.android.gms.SHARE_NEARBY") - .setType("text/plain") - .putExtra(Intent.EXTRA_TEXT, "Hello Nearby"); - -val packageManager = context.packageManager; -val activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); -// If the activities list is not empty, the intent can be handled and the intent can be called! -``` - -## Launching the settings page -The Google Quick Share settings page can be launched by sending an intent with the action ```com.google.android.gms.settings.SHARING```. There are no extras to be provided. - -Example code: -```kotlin -const val QUICK_SHARE_SETTINGS_INTENT = "com.google.android.gms.settings.SHARING" -context.startActivity(Intent(QUICK_SHARE_SETTINGS_INTENT)) -``` - -## Launching the receiving UI -The Google Quick Share receiving UI can be launched by sending an intent with the action ```com.google.android.gms.RECEIVE_NEARBY```. You will need to set the type of the intent to be `*/*` to match the filter. - -Example code: -```kotlin -const val QUICK_SHARE_RECEIVE_INTENT = "com.google.android.gms.RECEIVE_NEARBY" -context.startActivity(Intent(QUICK_SHARE_RECEIVE_INTENT).setType("*/*")) -``` - -## Sending a file via Quick Share -Quick Share responds to the `android.intent.action.SEND` intent. To send a file, attach a content URI to the Intent.EXTRA_STREAM when sending the intent to send a file via Quick Share. - -Example code: -```kotlin -val sendIntent = Intent(Intent.ACTION_SEND) - .setType(/* Set your content mime type here */) - .putExtra(Intent.EXTRA_STREAM, /* your content URI here */) -``` - -## Sending a folder via Quick Share -To send folders, Quick Share has a custom intent: `com.google.android.gms.nearby.SEND_FOLDER`. -### Mandatory extras -To place files in a parent folder, you can supply the following string extra: `com.google.android.gms.nearby.PARENT_FOLDER`. If this is not desirable, leave it as an empty string. - -To provide the file count of the number of the files in the folder, supply the following extra: `com.google.android.gms.nearby.FILE_COUNT`. If this is not supplied, Quick Share will assume 0 files are in the folder. - -To provide the actual content of the folder, supply the following extra: `com.google.android.gms.nearby.SEND_FOLDER_CONTENT_URI`. If not available, Quick Share will fail the transfer. - -### Content provider -To share a folder, Quick Share expects the presence of a ContentProvider with the following columns: - -`file_name` - The name of the file. - -`file_uri` - The URI of the file, as given by a file provider. - -`file_size` - The size in bytes of the file. - -`file_dir` - The directory that the file should be placed in (parent directory under `/sdcard/Download/Quick Share`). - -`file_mime_type` - The mime type of the file. - -Quick Share expects these columns to be populated for each file the user wants to share. The content URI provided is the URI to the content provider that can be queried for each file. - -Putting this all together, we have the following intent structure: -```kotlin -val sendFolderIntent = Intent("com.google.android.gms.nearby.SEND_FOLDER") - .putExtra("com.google.android.gms.nearby.PARENT_FOLDER", /* The folder to save to under /sdcard/Download/Quick Share */) - .putExtra("com.google.android.gms.nearby.FILE_COUNT", /* The file count in the folder */) - .putExtra("com.google.android.gms.nearby.SEND_FOLDER_CONTENT_URI", /* Your content provider URI here */) -``` - - -## Slice API +## The slice API The nearby module in GMSCore provides a third-party accessible slice to bind to, to provide live data on nearby targets using Nearby Share. Clicking on any of these targets will take you to the main Nearby Share screen, where the transfer will begin and continually update the progress. The slice URI is `content://com.google.android.gms.nearby.sharing/scan`. Upon first launch after install, you will be prompted to grant permission to the client application. After that, the slice will be kept up to date with the latest targets nearby. -### How to use the API -Example code: +## How to use the API ## +In Kotlin: ```kotlin // Derive the Slice URI. val sliceUri = Uri.parse("content://com.google.android.gms.nearby.sharing/scan") diff --git a/sharing/android/example/app/src/main/java/com/google/nearby/sharedemo/MainActivity.kt b/sharing/android/example/app/src/main/java/com/google/nearby/sharedemo/MainActivity.kt index f3fd72e3..c15d265c 100644 --- a/sharing/android/example/app/src/main/java/com/google/nearby/sharedemo/MainActivity.kt +++ b/sharing/android/example/app/src/main/java/com/google/nearby/sharedemo/MainActivity.kt @@ -72,22 +72,10 @@ class MainActivity : ComponentActivity() { onShareTargetClicked = { data, intent -> viewModel.onShareTargetClicked(data, this@MainActivity, intent) }) - - Button(onClick = { startActivity(Intent(QUICK_SHARE_SETTINGS_INTENT)) }) { - Text("Launch settings") - } - Button(onClick = { startActivity(Intent(QUICK_SHARE_RECEIVE_INTENT).setType("*/*")) }) { - Text("Launch receiving UI") - } } } } } - - companion object { - private const val QUICK_SHARE_SETTINGS_INTENT = "com.google.android.gms.settings.SHARING" - private const val QUICK_SHARE_RECEIVE_INTENT = "com.google.android.gms.RECEIVE_NEARBY" - } } @Composable diff --git a/sharing/android/example/build.gradle.kts b/sharing/android/example/build.gradle.kts index 77267e9e..002e6a6f 100644 --- a/sharing/android/example/build.gradle.kts +++ b/sharing/android/example/build.gradle.kts @@ -16,6 +16,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.2.2" apply false + id("com.android.application") version "8.1.1" apply false id("org.jetbrains.kotlin.android") version "1.8.10" apply false }