From b0ca53856ff984ecd74570c86ef849eeec09de4e Mon Sep 17 00:00:00 2001 From: robert-costello Date: Fri, 28 Jun 2024 16:16:41 -0400 Subject: [PATCH 1/6] add windowWidth to SessionWrapperclass and constructors --- .../commcare/modern/session/SessionWrapper.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/commcare/modern/session/SessionWrapper.java b/src/main/java/org/commcare/modern/session/SessionWrapper.java index f04aaee86..3098b3ae3 100644 --- a/src/main/java/org/commcare/modern/session/SessionWrapper.java +++ b/src/main/java/org/commcare/modern/session/SessionWrapper.java @@ -24,17 +24,19 @@ public class SessionWrapper extends CommCareSession implements SessionWrapperInt final protected CommCarePlatform mPlatform; protected CommCareInstanceInitializer initializer; protected RemoteInstanceFetcher remoteInstanceFetcher; + private String windowWidth; public SessionWrapper(CommCareSession session, CommCarePlatform platform, UserSandbox sandbox, - RemoteInstanceFetcher remoteInstanceFetcher) { - this(platform, sandbox, remoteInstanceFetcher); + RemoteInstanceFetcher remoteInstanceFetcher, String windowWidth) { + this(platform, sandbox, remoteInstanceFetcher, windowWidth); this.frame = session.getFrame(); this.setFrameStack(session.getFrameStack()); + this.windowWidth = windowWidth; } - public SessionWrapper(CommCareSession session, CommCarePlatform platform, UserSandbox sandbox) { - this(session, platform, sandbox, null); + public SessionWrapper(CommCareSession session, CommCarePlatform platform, UserSandbox sandbox, String windowWidth) { + this(session, platform, sandbox, null, windowWidth); } public SessionWrapper(CommCarePlatform platform, UserSandbox sandbox) { @@ -43,11 +45,12 @@ public SessionWrapper(CommCarePlatform platform, UserSandbox sandbox) { this.mPlatform = platform; } - public SessionWrapper(CommCarePlatform platform, UserSandbox sandbox, RemoteInstanceFetcher remoteInstanceFetcher) { + public SessionWrapper(CommCarePlatform platform, UserSandbox sandbox, RemoteInstanceFetcher remoteInstanceFetcher, String windowWidth) { super(platform); this.mSandbox = sandbox; this.mPlatform = platform; this.remoteInstanceFetcher = remoteInstanceFetcher; + this.windowWidth = windowWidth; } /** @@ -119,4 +122,8 @@ public void stepBack() { public RemoteInstanceFetcher getRemoteInstanceFetcher() { return remoteInstanceFetcher; } + + public String getWindowWidth() { + return this.windowWidth; + } } From dbf9e146891e97a337935525c3d2dc4ca019d8c0 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Fri, 28 Jun 2024 16:20:43 -0400 Subject: [PATCH 2/6] access windowWidth in initializer --- .../commcare/core/process/CommCareInstanceInitializer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/commcare/core/process/CommCareInstanceInitializer.java b/src/main/java/org/commcare/core/process/CommCareInstanceInitializer.java index ffacb76ce..c81004673 100644 --- a/src/main/java/org/commcare/core/process/CommCareInstanceInitializer.java +++ b/src/main/java/org/commcare/core/process/CommCareInstanceInitializer.java @@ -244,11 +244,15 @@ protected InstanceRoot setupSessionData(ExternalDataInstance instance) { TreeElement root = SessionInstanceBuilder.getSessionInstance(sessionWrapper.getFrame(), getDeviceId(), getVersionString(), getCurrentDrift(), u.getUsername(), u.getUniqueId(), - u.getProperties()); + u.getProperties(), getWindowWidth()); root.setParent(instance.getBase()); return new ConcreteInstanceRoot(root); } + protected String getWindowWidth() { + return sessionWrapper.getWindowWidth(); + } + protected long getCurrentDrift() { return 0; } From 2d1f8982ae1c3e658d3c2f74e80f040e1c0211b1 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Fri, 28 Jun 2024 16:22:03 -0400 Subject: [PATCH 3/6] add windowWidth to metedata --- .../java/org/commcare/session/SessionInstanceBuilder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/commcare/session/SessionInstanceBuilder.java b/src/main/java/org/commcare/session/SessionInstanceBuilder.java index 1c7b5b54b..db58158d6 100644 --- a/src/main/java/org/commcare/session/SessionInstanceBuilder.java +++ b/src/main/java/org/commcare/session/SessionInstanceBuilder.java @@ -17,11 +17,11 @@ public class SessionInstanceBuilder { public static TreeElement getSessionInstance(SessionFrame frame, String deviceId, String appversion, long drift, String username, String userId, - Hashtable userFields) { + Hashtable userFields, String windowWidth) { TreeElement sessionRoot = new TreeElement("session", 0); addSessionNavData(sessionRoot, frame); - addMetadata(sessionRoot, deviceId, appversion, username, userId, drift); + addMetadata(sessionRoot, deviceId, appversion, username, userId, drift, windowWidth); addUserProperties(sessionRoot, userFields); return sessionRoot; @@ -88,7 +88,7 @@ private static String getCalloutSearchResultCount(StackFrameStep step) { private static void addMetadata(TreeElement sessionRoot, String deviceId, String appversion, String username, - String userId, long drift) { + String userId, long drift, String windowWidth) { TreeElement sessionMeta = new TreeElement("context", 0); addData(sessionMeta, "deviceid", deviceId); @@ -96,6 +96,7 @@ private static void addMetadata(TreeElement sessionRoot, String deviceId, addData(sessionMeta, "username", username); addData(sessionMeta, "userid", userId); addData(sessionMeta, "drift", String.valueOf(drift)); + addData(sessionMeta, "windowwidth", windowWidth); sessionRoot.addChild(sessionMeta); } From 4b3e78fb65e094cd15c3a8a506c130e049111832 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Tue, 2 Jul 2024 14:46:19 -0400 Subject: [PATCH 4/6] add comment describing variable --- src/main/java/org/commcare/modern/session/SessionWrapper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/commcare/modern/session/SessionWrapper.java b/src/main/java/org/commcare/modern/session/SessionWrapper.java index 3098b3ae3..f51b96605 100644 --- a/src/main/java/org/commcare/modern/session/SessionWrapper.java +++ b/src/main/java/org/commcare/modern/session/SessionWrapper.java @@ -24,6 +24,10 @@ public class SessionWrapper extends CommCareSession implements SessionWrapperInt final protected CommCarePlatform mPlatform; protected CommCareInstanceInitializer initializer; protected RemoteInstanceFetcher remoteInstanceFetcher; + /** + * A string representing the width of the user's screen in pixels. + * To be used in a display condition determining what content to show to the user. + */ private String windowWidth; public SessionWrapper(CommCareSession session, CommCarePlatform platform, UserSandbox sandbox, From eaef2f00d430826f04b475414d27f088bb0c1f44 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Tue, 6 Aug 2024 12:11:53 -0400 Subject: [PATCH 5/6] change var name --- src/main/java/org/commcare/session/SessionInstanceBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/commcare/session/SessionInstanceBuilder.java b/src/main/java/org/commcare/session/SessionInstanceBuilder.java index db58158d6..060677d9b 100644 --- a/src/main/java/org/commcare/session/SessionInstanceBuilder.java +++ b/src/main/java/org/commcare/session/SessionInstanceBuilder.java @@ -96,7 +96,7 @@ private static void addMetadata(TreeElement sessionRoot, String deviceId, addData(sessionMeta, "username", username); addData(sessionMeta, "userid", userId); addData(sessionMeta, "drift", String.valueOf(drift)); - addData(sessionMeta, "windowwidth", windowWidth); + addData(sessionMeta, "window_width", windowWidth); sessionRoot.addChild(sessionMeta); } From 96f938b868444db6d2e74dbf12e0f6fe05590c74 Mon Sep 17 00:00:00 2001 From: robert-costello Date: Wed, 7 Aug 2024 10:31:15 -0400 Subject: [PATCH 6/6] remove redundant var assignment --- src/main/java/org/commcare/modern/session/SessionWrapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/commcare/modern/session/SessionWrapper.java b/src/main/java/org/commcare/modern/session/SessionWrapper.java index f51b96605..53c205da0 100644 --- a/src/main/java/org/commcare/modern/session/SessionWrapper.java +++ b/src/main/java/org/commcare/modern/session/SessionWrapper.java @@ -35,7 +35,6 @@ public SessionWrapper(CommCareSession session, CommCarePlatform platform, UserSa this(platform, sandbox, remoteInstanceFetcher, windowWidth); this.frame = session.getFrame(); this.setFrameStack(session.getFrameStack()); - this.windowWidth = windowWidth; }