Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc/core make widow width available in session #1414

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/org/commcare/modern/session/SessionWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ public class SessionWrapper extends CommCareSession implements SessionWrapperInt
final protected CommCarePlatform mPlatform;
protected CommCareInstanceInitializer initializer;
protected RemoteInstanceFetcher remoteInstanceFetcher;
private String windowWidth;
shubham1g5 marked this conversation as resolved.
Show resolved Hide resolved

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that covered by the call on line 57?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think you're right

}


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) {
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -119,4 +122,8 @@ public void stepBack() {
public RemoteInstanceFetcher getRemoteInstanceFetcher() {
return remoteInstanceFetcher;
}

public String getWindowWidth() {
return this.windowWidth;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class SessionInstanceBuilder {
public static TreeElement getSessionInstance(SessionFrame frame, String deviceId,
String appversion, long drift,
String username, String userId,
Hashtable<String, String> userFields) {
Hashtable<String, String> 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;
Expand Down Expand Up @@ -88,14 +88,15 @@ 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);
addData(sessionMeta, "appversion", appversion);
addData(sessionMeta, "username", username);
addData(sessionMeta, "userid", userId);
addData(sessionMeta, "drift", String.valueOf(drift));
addData(sessionMeta, "windowwidth", windowWidth);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

windowwidth troubles me a bit, can we underscore it as window_width although inconsistent with other params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll change it to window_width


sessionRoot.addChild(sessionMeta);
}
Expand Down
Loading