Commit 7df3c64a authored by Jan Lamecki's avatar Jan Lamecki Committed by Commit Bot

Use java_cpp_enum on VisibilityType, GestureType and VisibilityPriority.

Also:
 * make actions needed by CastWebContents{Fragment,View} in
   CastWebContentsIntentUtils public.
 * use generated annotation generated by java_cpp_enum on methods
   working with mentioned enums. This serves as documentation/pseudo
   type-safety and can be used by some tools (for example IDEs).

Test: NONE.
Bug: internal b/112463440.
Change-Id: I74c301c4bc20ae8c6c1353f5d082b533a93878ae
Reviewed-on: https://chromium-review.googlesource.com/c/1353932
Commit-Queue: Jan Lamecki <jachor@google.com>
Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612620}
parent 7dc7339f
...@@ -545,4 +545,10 @@ if (is_android) { ...@@ -545,4 +545,10 @@ if (is_android) {
jni_package = "chromecast" jni_package = "chromecast"
} }
java_cpp_enum("java_enums") {
sources = [
"cast_content_window.h",
]
}
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//chromecast/chromecast.gni")
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
import("//chromecast/chromecast.gni")
import("//media/media_options.gni") import("//media/media_options.gni")
assert(is_android) assert(is_android)
...@@ -129,6 +129,7 @@ android_library("cast_shell_java") { ...@@ -129,6 +129,7 @@ android_library("cast_shell_java") {
srcjar_deps = [ srcjar_deps = [
":cast_shell_build_config_gen", ":cast_shell_build_config_gen",
":logs_provider_aidl", ":logs_provider_aidl",
"//chromecast/browser:java_enums",
] ]
deps = [ deps = [
......
...@@ -55,21 +55,21 @@ public class CastWebContentsIntentUtils { ...@@ -55,21 +55,21 @@ public class CastWebContentsIntentUtils {
/** /**
* Action type of intent from cast app to android to request for a visibility priority change. * Action type of intent from cast app to android to request for a visibility priority change.
*/ */
static final String ACTION_REQUEST_VISIBILITY_PRIORITY = public static final String ACTION_REQUEST_VISIBILITY_PRIORITY =
"com.google.android.apps.castshell.intent.action.REQUEST_VISIBILITY_PRIORITY"; "com.google.android.apps.castshell.intent.action.REQUEST_VISIBILITY_PRIORITY";
/** /**
* Action type of intent from CastShell to external acivity to notify whether the gesture * Action type of intent from CastShell to external acivity to notify whether the gesture
* has been consumed. * has been consumed.
*/ */
static final String ACTION_GESTURE_CONSUMED = public static final String ACTION_GESTURE_CONSUMED =
"com.google.android.apps.castshell.intent.action.GESTURE_CONSUMED"; "com.google.android.apps.castshell.intent.action.GESTURE_CONSUMED";
/** /**
* Action type of intent from cast app to android to request to move the cast view out of * Action type of intent from cast app to android to request to move the cast view out of
* screen. * screen.
*/ */
static final String ACTION_REQUEST_MOVE_OUT = public static final String ACTION_REQUEST_MOVE_OUT =
"com.google.android.apps.castshell.intent.action.REQUEST_MOVE_OUT"; "com.google.android.apps.castshell.intent.action.REQUEST_MOVE_OUT";
/** /**
...@@ -136,17 +136,20 @@ public class CastWebContentsIntentUtils { ...@@ -136,17 +136,20 @@ public class CastWebContentsIntentUtils {
"com.google.android.apps.castshell.intent.extra.GESTURE_TYPE"; "com.google.android.apps.castshell.intent.extra.GESTURE_TYPE";
/** /**
* Key of extra value of the intent ACTION_GUESTURE_CONSUMED, value is whether gesture * Key of extra value of the intent ACTION_GESTURE_CONSUMED, value is whether gesture
* is consumed(consumed: true, not: false). * is consumed(consumed: true, not: false).
*/ */
private static final String INTENT_EXTRA_GESTURE_CONSUMED = private static final String INTENT_EXTRA_GESTURE_CONSUMED =
"com.google.android.apps.castshell.intent.extra.GESTURE_CONSUMED"; "com.google.android.apps.castshell.intent.extra.GESTURE_CONSUMED";
// Matches to chromecast::shell::VisibilityPriority @VisibilityType
static final int VISIBITY_TYPE_UNKNOWN = 0; static final int VISIBITY_TYPE_UNKNOWN = VisibilityType.UNKNOWN;
static final int VISIBITY_TYPE_FULL_SCREEN = 1; @VisibilityType
static final int VISIBITY_TYPE_PARTIAL_OUT = 2; static final int VISIBITY_TYPE_FULL_SCREEN = VisibilityType.FULL_SCREEN;
static final int VISIBITY_TYPE_HIDDEN = 3; @VisibilityType
static final int VISIBITY_TYPE_PARTIAL_OUT = VisibilityType.PARTIAL_OUT;
@VisibilityType
static final int VISIBITY_TYPE_HIDDEN = VisibilityType.HIDDEN;
// CastWebContentsSurfaceHelper -> CastWebContentsComponent.Receiver // CastWebContentsSurfaceHelper -> CastWebContentsComponent.Receiver
// -> CastContentWindowAndroid // -> CastContentWindowAndroid
...@@ -157,17 +160,17 @@ public class CastWebContentsIntentUtils { ...@@ -157,17 +160,17 @@ public class CastWebContentsIntentUtils {
// Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver // Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver
// -> CastContentWindowAndroid // -> CastContentWindowAndroid
public static Intent onGesture(String instanceId, int gestureType) { public static Intent onGesture(String instanceId, @GestureType int gestureType) {
return onGesture(getInstanceUri(instanceId), gestureType); return onGesture(getInstanceUri(instanceId), gestureType);
} }
// Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver // Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver
// -> CastContentWindowAndroid // -> CastContentWindowAndroid
public static Intent onGestureWithUriString(String uri, int gestureType) { public static Intent onGestureWithUriString(String uri, @GestureType int gestureType) {
return onGesture(Uri.parse(uri), gestureType); return onGesture(Uri.parse(uri), gestureType);
} }
private static Intent onGesture(Uri uri, int gestureType) { private static Intent onGesture(Uri uri, @GestureType int gestureType) {
if (DEBUG) Log.d(TAG, "onGesture with uri:" + uri + " type:" + gestureType); if (DEBUG) Log.d(TAG, "onGesture with uri:" + uri + " type:" + gestureType);
Intent intent = new Intent(ACTION_ON_GESTURE, uri); Intent intent = new Intent(ACTION_ON_GESTURE, uri);
intent.putExtra(INTENT_EXTRA_GESTURE_TYPE, gestureType); intent.putExtra(INTENT_EXTRA_GESTURE_TYPE, gestureType);
...@@ -184,17 +187,18 @@ public class CastWebContentsIntentUtils { ...@@ -184,17 +187,18 @@ public class CastWebContentsIntentUtils {
// Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver // Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver
// -> CastContentWindowAndroid // -> CastContentWindowAndroid
public static Intent onVisibilityChange(String instanceId, int visibilityType) { public static Intent onVisibilityChange(String instanceId, @VisibilityType int visibilityType) {
return onVisibilityChange(getInstanceUri(instanceId), visibilityType); return onVisibilityChange(getInstanceUri(instanceId), visibilityType);
} }
// Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver // Host activity of CastWebContentsFragment -> CastWebContentsComponent.Receiver
// -> CastContentWindowAndroid // -> CastContentWindowAndroid
public static Intent onVisibilityChangeWithUriString(String uri, int visibilityType) { public static Intent onVisibilityChangeWithUriString(
String uri, @VisibilityType int visibilityType) {
return onVisibilityChange(Uri.parse(uri), visibilityType); return onVisibilityChange(Uri.parse(uri), visibilityType);
} }
private static Intent onVisibilityChange(Uri uri, int visibilityType) { private static Intent onVisibilityChange(Uri uri, @VisibilityType int visibilityType) {
if (DEBUG) Log.d(TAG, "onVisibilityChange with uri:" + uri + " type:" + visibilityType); if (DEBUG) Log.d(TAG, "onVisibilityChange with uri:" + uri + " type:" + visibilityType);
Intent intent = new Intent(ACTION_ON_VISIBILITY_CHANGE, uri); Intent intent = new Intent(ACTION_ON_VISIBILITY_CHANGE, uri);
...@@ -210,7 +214,8 @@ public class CastWebContentsIntentUtils { ...@@ -210,7 +214,8 @@ public class CastWebContentsIntentUtils {
} }
// CastContentWindowAndroid -> Host activity of CastWebContentsFragment // CastContentWindowAndroid -> Host activity of CastWebContentsFragment
public static Intent requestVisibilityPriority(String instanceId, int visibilityPriority) { public static Intent requestVisibilityPriority(
String instanceId, @VisibilityPriority int visibilityPriority) {
Intent intent = new Intent(ACTION_REQUEST_VISIBILITY_PRIORITY); Intent intent = new Intent(ACTION_REQUEST_VISIBILITY_PRIORITY);
intent.putExtra(INTENT_EXTRA_URI, getInstanceUri(instanceId).toString()); intent.putExtra(INTENT_EXTRA_URI, getInstanceUri(instanceId).toString());
intent.putExtra(INTENT_EXTRA_VISIBILITY_PRIORITY, visibilityPriority); intent.putExtra(INTENT_EXTRA_VISIBILITY_PRIORITY, visibilityPriority);
...@@ -218,7 +223,8 @@ public class CastWebContentsIntentUtils { ...@@ -218,7 +223,8 @@ public class CastWebContentsIntentUtils {
} }
// CastWebContentsComponent.Receiver -> Host activity of CastWebContentsFragment // CastWebContentsComponent.Receiver -> Host activity of CastWebContentsFragment
public static Intent gestureConsumed(String instanceId, int gestureType, boolean consumed) { public static Intent gestureConsumed(
String instanceId, @GestureType int gestureType, boolean consumed) {
Intent intent = new Intent(ACTION_GESTURE_CONSUMED); Intent intent = new Intent(ACTION_GESTURE_CONSUMED);
intent.putExtra(INTENT_EXTRA_URI, getInstanceUri(instanceId).toString()); intent.putExtra(INTENT_EXTRA_URI, getInstanceUri(instanceId).toString());
intent.putExtra(INTENT_EXTRA_GESTURE_TYPE, gestureType); intent.putExtra(INTENT_EXTRA_GESTURE_TYPE, gestureType);
...@@ -227,6 +233,7 @@ public class CastWebContentsIntentUtils { ...@@ -227,6 +233,7 @@ public class CastWebContentsIntentUtils {
} }
// Used by intent of ACTION_ON_GESTURE // Used by intent of ACTION_ON_GESTURE
@GestureType
public static int getGestureType(Intent in) { public static int getGestureType(Intent in) {
return in.getIntExtra(INTENT_EXTRA_GESTURE_TYPE, 0); return in.getIntExtra(INTENT_EXTRA_GESTURE_TYPE, 0);
} }
...@@ -237,26 +244,29 @@ public class CastWebContentsIntentUtils { ...@@ -237,26 +244,29 @@ public class CastWebContentsIntentUtils {
} }
// Used by intent of ACTION_ON_VISIBILITY_CHANGE // Used by intent of ACTION_ON_VISIBILITY_CHANGE
@VisibilityType
public static int getVisibilityType(Intent in) { public static int getVisibilityType(Intent in) {
return in.getIntExtra(INTENT_EXTRA_VISIBILITY_TYPE, 0); return in.getIntExtra(INTENT_EXTRA_VISIBILITY_TYPE, 0);
} }
// Used by intent of ACTION_KEY_EVENT // Used by intent of ACTION_REQUEST_VISIBILITY_PRIORITY, ACTION_SHOW_WEB_CONTENT
@VisibilityPriority
public static int getVisibilityPriority(Bundle bundle) { public static int getVisibilityPriority(Bundle bundle) {
return bundle.getInt(INTENT_EXTRA_VISIBILITY_PRIORITY, 0); return bundle.getInt(INTENT_EXTRA_VISIBILITY_PRIORITY, 0);
} }
// Used by intent of ACTION_REQUEST_VISIBILITY_PRIORITY, ACTION_SHOW_WEB_CONTENT // Used by intent of ACTION_REQUEST_VISIBILITY_PRIORITY, ACTION_SHOW_WEB_CONTENT
@VisibilityPriority
public static int getVisibilityPriority(Intent in) { public static int getVisibilityPriority(Intent in) {
return getVisibilityPriority(in.getExtras()); return getVisibilityPriority(in.getExtras());
} }
// Used by intent of ACTION_REQUEST_VISIBILITY_PRIORITY, ACTION_SHOW_WEB_CONTENT // Used by intent of ACTION_GESTURE_CONSUMED
public static boolean isGestureConsumed(Intent in) { public static boolean isGestureConsumed(Intent in) {
return isGestureConsumed(in.getExtras()); return isGestureConsumed(in.getExtras());
} }
// Used by intent of ACTION_REQUEST_VISIBILITY_PRIORITY, ACTION_SHOW_WEB_CONTENT // Used by intent of ACTION_GESTURE_CONSUMED
public static boolean isGestureConsumed(Bundle bundle) { public static boolean isGestureConsumed(Bundle bundle) {
return bundle.getBoolean(INTENT_EXTRA_GESTURE_CONSUMED); return bundle.getBoolean(INTENT_EXTRA_GESTURE_CONSUMED);
} }
...@@ -303,7 +313,7 @@ public class CastWebContentsIntentUtils { ...@@ -303,7 +313,7 @@ public class CastWebContentsIntentUtils {
// CastWebContentsComponent.Receiver -> Host activity of CastWebContentsFragment // CastWebContentsComponent.Receiver -> Host activity of CastWebContentsFragment
public static Intent requestStartCastFragment(WebContents webContents, String appId, public static Intent requestStartCastFragment(WebContents webContents, String appId,
int visibilityPriority, boolean enableTouch, String instanceId, @VisibilityPriority int visibilityPriority, boolean enableTouch, String instanceId,
boolean isRemoteControlMode, boolean turnOnScreen) { boolean isRemoteControlMode, boolean turnOnScreen) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(CastIntents.ACTION_SHOW_WEB_CONTENT); intent.setAction(CastIntents.ACTION_SHOW_WEB_CONTENT);
......
...@@ -21,6 +21,7 @@ namespace chromecast { ...@@ -21,6 +21,7 @@ namespace chromecast {
namespace shell { namespace shell {
// Describes visual context of the window within the UI. // Describes visual context of the window within the UI.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chromecast.shell
enum class VisibilityType { enum class VisibilityType {
// Unknown visibility state. // Unknown visibility state.
UNKNOWN = 0, UNKNOWN = 0,
...@@ -43,6 +44,7 @@ enum class VisibilityType { ...@@ -43,6 +44,7 @@ enum class VisibilityType {
// 2. Whether the window should become immediately visible // 2. Whether the window should become immediately visible
// 3. How much screen space the window should occupy // 3. How much screen space the window should occupy
// 4. What state to return to when the activity is completed // 4. What state to return to when the activity is completed
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chromecast.shell
enum class VisibilityPriority { enum class VisibilityPriority {
// Default priority. It is up to system to decide how to show the activity. // Default priority. It is up to system to decide how to show the activity.
DEFAULT = 0, DEFAULT = 0,
...@@ -72,6 +74,7 @@ enum class VisibilityPriority { ...@@ -72,6 +74,7 @@ enum class VisibilityPriority {
HIDDEN_STICKY = 6, HIDDEN_STICKY = 6,
}; };
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chromecast.shell
enum class GestureType { enum class GestureType {
NO_GESTURE = 0, NO_GESTURE = 0,
GO_BACK = 1, GO_BACK = 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment