summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-02-13 22:23:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-02-13 22:23:11 +0000
commit7669e6b8b45bdbe7f5ce4e93ff0c90bc471723ba (patch)
tree49609174154b043eb27f489b38cecc2be143c990 /java
parent249753fec137c15b09f80712001fa9d78dc10ce7 (diff)
parentbf789564b55e260634723921b1065fdd8f4f1147 (diff)
Merge "Use new shareousel API constants" into main
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/intentresolver/contentpreview/CursorUriReader.kt17
-rw-r--r--java/src/com/android/intentresolver/contentpreview/SelectionChangeCallback.kt6
-rw-r--r--java/src/com/android/intentresolver/v2/ui/viewmodel/ChooserRequestReader.kt11
3 files changed, 13 insertions, 21 deletions
diff --git a/java/src/com/android/intentresolver/contentpreview/CursorUriReader.kt b/java/src/com/android/intentresolver/contentpreview/CursorUriReader.kt
index 7ff3b49e..e9e60040 100644
--- a/java/src/com/android/intentresolver/contentpreview/CursorUriReader.kt
+++ b/java/src/com/android/intentresolver/contentpreview/CursorUriReader.kt
@@ -23,16 +23,13 @@ import android.database.MatrixCursor
import android.net.Uri
import android.os.Bundle
import android.os.CancellationSignal
+import android.service.chooser.AdditionalContentContract.Columns
+import android.service.chooser.AdditionalContentContract.CursorExtraKeys
import android.util.Log
import android.util.SparseArray
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.coroutineScope
-// TODO: replace with the new API AdditionalContentContract$Columns#URI
-private const val ColumnUri = "uri"
-// TODO: replace with the new API AdditionalContentContract$CursorExtraKeys#POSITION
-private const val ExtraPosition = "position"
-
private const val TAG = ContentPreviewUi.TAG
/**
@@ -124,7 +121,7 @@ class CursorUriReader(
runCatching {
contentResolver.query(
uri,
- arrayOf(ColumnUri),
+ arrayOf(Columns.URI),
Bundle().apply {
putParcelable(Intent.EXTRA_INTENT, chooserIntent)
},
@@ -132,13 +129,17 @@ class CursorUriReader(
)
}
.getOrNull()
- ?: MatrixCursor(arrayOf(ColumnUri))
+ ?: MatrixCursor(arrayOf(Columns.URI))
}
} catch (e: CancellationException) {
cancellationSignal.cancel()
throw e
}
- return CursorUriReader(cursor, cursor.extras?.getInt(ExtraPosition, 0) ?: 0, 128) {
+ return CursorUriReader(
+ cursor,
+ cursor.extras?.getInt(CursorExtraKeys.POSITION, 0) ?: 0,
+ 128,
+ ) {
// TODO: check that authority is case-sensitive for resolution reasons
it.authority != uri.authority
}
diff --git a/java/src/com/android/intentresolver/contentpreview/SelectionChangeCallback.kt b/java/src/com/android/intentresolver/contentpreview/SelectionChangeCallback.kt
index 2cc58a97..4e2e37b8 100644
--- a/java/src/com/android/intentresolver/contentpreview/SelectionChangeCallback.kt
+++ b/java/src/com/android/intentresolver/contentpreview/SelectionChangeCallback.kt
@@ -22,12 +22,10 @@ import android.content.Intent.EXTRA_CHOOSER_CUSTOM_ACTIONS
import android.content.Intent.EXTRA_INTENT
import android.net.Uri
import android.os.Bundle
+import android.service.chooser.AdditionalContentContract.MethodNames.ON_SELECTION_CHANGED
import android.service.chooser.ChooserAction
import com.android.intentresolver.contentpreview.PayloadToggleInteractor.CallbackResult
-// TODO: replace with the new API AdditionalContentContract$MethodNames#ON_SELECTION_CHANGED
-private const val MethodName = "onSelectionChanged"
-
/**
* Encapsulates payload change callback invocation to the sharing app; handles callback arguments
* and result format mapping.
@@ -41,7 +39,7 @@ class SelectionChangeCallback(
contentResolver
.call(
requireNotNull(uri.authority) { "URI authority can not be null" },
- MethodName,
+ ON_SELECTION_CHANGED,
uri.toString(),
Bundle().apply {
putParcelable(
diff --git a/java/src/com/android/intentresolver/v2/ui/viewmodel/ChooserRequestReader.kt b/java/src/com/android/intentresolver/v2/ui/viewmodel/ChooserRequestReader.kt
index 0269168e..565d4de1 100644
--- a/java/src/com/android/intentresolver/v2/ui/viewmodel/ChooserRequestReader.kt
+++ b/java/src/com/android/intentresolver/v2/ui/viewmodel/ChooserRequestReader.kt
@@ -60,13 +60,6 @@ import com.android.intentresolver.v2.validation.validateFrom
private const val MAX_CHOOSER_ACTIONS = 5
private const val MAX_INITIAL_INTENTS = 2
-// TODO: replace with the new API constant, Intent#EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI
-private const val EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI =
- "android.intent.extra.CHOOSER_ADDITIONAL_CONTENT_URI"
-// TODO: replace with the new API constant, Intent#EXTRA_CHOOSER_FOCUSED_ITEM_POSITION
-private const val EXTRA_CHOOSER_FOCUSED_ITEM_POSITION =
- "android.intent.extra.CHOOSER_FOCUSED_ITEM_POSITION"
-
private fun Intent.hasSendAction() = hasAction(ACTION_SEND, ACTION_SEND_MULTIPLE)
internal fun Intent.maybeAddSendActionFlags() =
@@ -143,8 +136,8 @@ fun readChooserRequest(
val additionalContentUri: Uri?
val focusedItemPos: Int
if (isSendAction && flags.chooserPayloadToggling()) {
- additionalContentUri = optional(value<Uri>(EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI))
- focusedItemPos = optional(value<Int>(EXTRA_CHOOSER_FOCUSED_ITEM_POSITION)) ?: 0
+ additionalContentUri = optional(value<Uri>(Intent.EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI))
+ focusedItemPos = optional(value<Int>(Intent.EXTRA_CHOOSER_FOCUSED_ITEM_POSITION)) ?: 0
} else {
additionalContentUri = null
focusedItemPos = 0