Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 01bdf81

Browse files
committed
[Android] Convert int in Dart to long instead of int in java.
1 parent 35934fd commit 01bdf81

19 files changed

Lines changed: 100 additions & 98 deletions

shell/platform/android/android_context_gl_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MockPlatformViewAndroidJNI : public PlatformViewAndroidJNI {
3939
MOCK_METHOD1(SurfaceTextureDetachFromGLContext,
4040
void(JavaLocalRef surface_texture));
4141
MOCK_METHOD8(FlutterViewOnDisplayPlatformView,
42-
void(int view_id,
42+
void(int64_t view_id,
4343
int x,
4444
int y,
4545
int width,

shell/platform/android/android_shell_holder_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MockPlatformViewAndroidJNI : public PlatformViewAndroidJNI {
3131
MOCK_METHOD1(SurfaceTextureDetachFromGLContext,
3232
void(JavaLocalRef surface_texture));
3333
MOCK_METHOD8(FlutterViewOnDisplayPlatformView,
34-
void(int view_id,
34+
void(int64_t view_id,
3535
int x,
3636
int y,
3737
int width,

shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ private native void nativeDeferredComponentInstallFailure(
13821382
// @SuppressWarnings("unused")
13831383
@UiThread
13841384
public void onDisplayPlatformView(
1385-
int viewId,
1385+
long viewId,
13861386
int x,
13871387
int y,
13881388
int width,

shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PlatformViewsChannel {
2828
private final MethodChannel channel;
2929
private PlatformViewsHandler handler;
3030

31-
public void invokeViewFocused(int viewId) {
31+
public void invokeViewFocused(long viewId) {
3232
if (channel == null) {
3333
return;
3434
}
@@ -93,7 +93,7 @@ private void create(@NonNull MethodCall call, @NonNull MethodChannel.Result resu
9393
if (usesPlatformViewLayer) {
9494
final PlatformViewCreationRequest request =
9595
new PlatformViewCreationRequest(
96-
(int) createArgs.get("id"),
96+
((Number) createArgs.get("id")).longValue(),
9797
(String) createArgs.get("viewType"),
9898
0,
9999
0,
@@ -116,7 +116,7 @@ private void create(@NonNull MethodCall call, @NonNull MethodChannel.Result resu
116116
.TEXTURE_WITH_VIRTUAL_FALLBACK;
117117
final PlatformViewCreationRequest request =
118118
new PlatformViewCreationRequest(
119-
(int) createArgs.get("id"),
119+
((Number) createArgs.get("id")).longValue(),
120120
(String) createArgs.get("viewType"),
121121
createArgs.containsKey("top") ? (double) createArgs.get("top") : 0.0,
122122
createArgs.containsKey("left") ? (double) createArgs.get("left") : 0.0,
@@ -144,7 +144,7 @@ private void create(@NonNull MethodCall call, @NonNull MethodChannel.Result resu
144144

145145
private void dispose(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
146146
Map<String, Object> disposeArgs = call.arguments();
147-
int viewId = (int) disposeArgs.get("id");
147+
long viewId = ((Number) disposeArgs.get("id")).longValue();
148148

149149
try {
150150
handler.dispose(viewId);
@@ -158,7 +158,7 @@ private void resize(@NonNull MethodCall call, @NonNull MethodChannel.Result resu
158158
Map<String, Object> resizeArgs = call.arguments();
159159
PlatformViewResizeRequest resizeRequest =
160160
new PlatformViewResizeRequest(
161-
(int) resizeArgs.get("id"),
161+
((Number) resizeArgs.get("id")).longValue(),
162162
(double) resizeArgs.get("width"),
163163
(double) resizeArgs.get("height"));
164164
try {
@@ -183,7 +183,7 @@ private void offset(@NonNull MethodCall call, @NonNull MethodChannel.Result resu
183183
Map<String, Object> offsetArgs = call.arguments();
184184
try {
185185
handler.offset(
186-
(int) offsetArgs.get("id"),
186+
((Number) offsetArgs.get("id")).longValue(),
187187
(double) offsetArgs.get("top"),
188188
(double) offsetArgs.get("left"));
189189
result.success(null);
@@ -223,7 +223,7 @@ private void touch(@NonNull MethodCall call, @NonNull MethodChannel.Result resul
223223

224224
private void setDirection(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
225225
Map<String, Object> setDirectionArgs = call.arguments();
226-
int newDirectionViewId = (int) setDirectionArgs.get("id");
226+
long newDirectionViewId = ((Number) setDirectionArgs.get("id")).longValue();
227227
int direction = (int) setDirectionArgs.get("direction");
228228

229229
try {
@@ -235,7 +235,7 @@ private void setDirection(@NonNull MethodCall call, @NonNull MethodChannel.Resul
235235
}
236236

237237
private void clearFocus(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
238-
int viewId = call.arguments();
238+
long viewId = call.arguments();
239239
try {
240240
handler.clearFocus(viewId);
241241
result.success(null);
@@ -319,7 +319,7 @@ public interface PlatformViewsHandler {
319319
long createForTextureLayer(@NonNull PlatformViewCreationRequest request);
320320

321321
/** The Flutter application would like to dispose of an existing Android {@code View}. */
322-
void dispose(int viewId);
322+
void dispose(long viewId);
323323

324324
/**
325325
* The Flutter application would like to resize an existing Android {@code View}.
@@ -334,7 +334,7 @@ void resize(
334334
/**
335335
* The Flutter application would like to change the offset of an existing Android {@code View}.
336336
*/
337-
void offset(int viewId, double top, double left);
337+
void offset(long viewId, double top, double left);
338338

339339
/**
340340
* The user touched a platform view within Flutter.
@@ -348,10 +348,10 @@ void resize(
348348
* {@code View}, i.e., platform view.
349349
*/
350350
// TODO(mattcarroll): Introduce an annotation for @TextureId
351-
void setDirection(int viewId, int direction);
351+
void setDirection(long viewId, int direction);
352352

353353
/** Clears the focus from the platform view with a give id if it is currently focused. */
354-
void clearFocus(int viewId);
354+
void clearFocus(long viewId);
355355

356356
/**
357357
* Whether the render surface of {@code FlutterView} should be converted to a {@code
@@ -376,7 +376,7 @@ public enum RequestedDisplayMode {
376376
}
377377

378378
/** The ID of the platform view as seen by the Flutter side. */
379-
public final int viewId;
379+
public final long viewId;
380380

381381
/** The type of Android {@code View} to create for this platform view. */
382382
@NonNull public final String viewType;
@@ -408,7 +408,7 @@ public enum RequestedDisplayMode {
408408

409409
/** Creates a request to construct a platform view. */
410410
public PlatformViewCreationRequest(
411-
int viewId,
411+
long viewId,
412412
@NonNull String viewType,
413413
double logicalTop,
414414
double logicalLeft,
@@ -430,7 +430,7 @@ public PlatformViewCreationRequest(
430430

431431
/** Creates a request to construct a platform view with the given display mode. */
432432
public PlatformViewCreationRequest(
433-
int viewId,
433+
long viewId,
434434
@NonNull String viewType,
435435
double logicalTop,
436436
double logicalLeft,
@@ -454,15 +454,15 @@ public PlatformViewCreationRequest(
454454
/** Request sent from Flutter to resize a platform view. */
455455
public static class PlatformViewResizeRequest {
456456
/** The ID of the platform view as seen by the Flutter side. */
457-
public final int viewId;
457+
public final long viewId;
458458

459459
/** The new density independent width to display the platform view. */
460460
public final double newLogicalWidth;
461461

462462
/** The new density independent height to display the platform view. */
463463
public final double newLogicalHeight;
464464

465-
public PlatformViewResizeRequest(int viewId, double newLogicalWidth, double newLogicalHeight) {
465+
public PlatformViewResizeRequest(long viewId, double newLogicalWidth, double newLogicalHeight) {
466466
this.viewId = viewId;
467467
this.newLogicalWidth = newLogicalWidth;
468468
this.newLogicalHeight = newLogicalHeight;
@@ -491,7 +491,7 @@ public interface PlatformViewBufferResized {
491491
/** The state of a touch event in Flutter within a platform view. */
492492
public static class PlatformViewTouch {
493493
/** The ID of the platform view as seen by the Flutter side. */
494-
public final int viewId;
494+
public final long viewId;
495495

496496
/** The amount of time that the touch has been pressed. */
497497
@NonNull public final Number downTime;
@@ -525,7 +525,7 @@ public static class PlatformViewTouch {
525525
public final long motionEventId;
526526

527527
public PlatformViewTouch(
528-
int viewId,
528+
long viewId,
529529
@NonNull Number downTime,
530530
@NonNull Number eventTime,
531531
int action,

shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public InputConnection getLastInputConnection() {
369369
* <p>This is called when a platform view is disposed to make sure we're not hanging to a stale
370370
* input connection.
371371
*/
372-
public void clearPlatformViewClient(int platformViewId) {
372+
public void clearPlatformViewClient(long platformViewId) {
373373
if ((inputTarget.type == InputTarget.Type.VIRTUAL_DISPLAY_PLATFORM_VIEW
374374
|| inputTarget.type == InputTarget.Type.PHYSICAL_DISPLAY_PLATFORM_VIEW)
375375
&& inputTarget.id == platformViewId) {

shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public PlatformViewFactory(@Nullable MessageCodec<Object> createArgsCodec) {
2828
* null, or no arguments were sent from the Flutter app.
2929
*/
3030
@NonNull
31-
public abstract PlatformView create(Context context, int viewId, @Nullable Object args);
31+
public abstract PlatformView create(Context context, long viewId, @Nullable Object args);
3232

3333
/** Returns the codec to be used for decoding the args parameter of {@link #create}. */
3434
@Nullable

shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public interface PlatformViewsAccessibilityDelegate {
1616
* there is no corresponding view.
1717
*/
1818
@Nullable
19-
View getPlatformViewById(int viewId);
19+
View getPlatformViewById(long viewId);
2020

2121
/** Returns true if the platform view uses virtual displays. */
22-
boolean usesVirtualDisplay(int id);
22+
boolean usesVirtualDisplay(long viewId);
2323

2424
/**
2525
* Attaches an accessibility bridge for this platform views accessibility delegate.

0 commit comments

Comments
 (0)