Skip to content
Snippets Groups Projects
Commit f9526047 authored by ect1u17's avatar ect1u17
Browse files

Changes since last commit:

- Removed Auth0 integration (un-needed)
- Implemented MongoDB connections, sync and restore from remote DB
- Small bug fixes
parent ab2e8ddf
Branches
No related tags found
No related merge requests found
Showing
with 2475 additions and 1064 deletions
<component name="ProjectDictionaryState">
<dictionary name="eamon">
<words>
<w>mongo</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java" charset="windows-1252" />
<file url="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" charset="ISO-8859-1" />
</component>
</project>
\ No newline at end of file
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="com.yearthreeproject.xbframework" />
<option name="TOOL_WINDOW_LOG_LEVEL" value="verbose" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" />
</component>
<component name="ChangeListManager">
<list default="true" id="901156b8-4ed3-48c9-9feb-1fa598856dd4" name="Default Changelist" comment="Changes since last commit:&#10;- Colour changes for most pages">
<change afterPath="$PROJECT_DIR$/app/src/main/res/raw/local_user_data.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/content_login.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/content_login.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/content_progress.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/content_progress.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/styles.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/styles.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CodeInsightWorkspaceSettings">
<option name="optimizeImportsOnTheFly" value="true" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_2_API_29" />
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="ExternalProjectsManager">
<system id="GRADLE">
<state>
<task path="$PROJECT_DIR$">
<activation />
</task>
<task path="$PROJECT_DIR$/app">
<activation />
</task>
<projects_view>
<tree_state>
<expand />
<select />
</tree_state>
</projects_view>
</state>
</system>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="layoutResourceFile_vertical" />
<option value="Class" />
<option value="resourceFile" />
<option value="valueResourceFile" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1YGdFr4LLCXPCzaKdUL32gvMs2q" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="DeviceAndSnapshotComboBoxAction.selectedDevice" value="Pixel_2_API_29" />
<property name="DeviceAndSnapshotComboBoxAction.selectionTime" value="2020-02-11T20:50:41.427Z" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="android.sdk.path" value="$USER_HOME$/AppData/Local/Android/Sdk" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Suggestions" />
<property name="project.structure.proportion" value="0.17" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
<property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\" />
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\drawable-xxhdpi" />
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\raw" />
</key>
<key name="CreateClassDialog.RecentsKey">
<recent name="com.yearthreeproject.xbframework" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
<option name="TEST_OBJECT" value="class" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="app" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="app" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sample Java Methods" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="901156b8-4ed3-48c9-9feb-1fa598856dd4" name="Default Changelist" comment="" />
<created>1572372213329</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1572372213329</updated>
</task>
<task id="LOCAL-00001" summary="Change to v0.0.1">
<created>1573421262618</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1573421262618</updated>
</task>
<task id="LOCAL-00002" summary="Change to v0.0.2">
<created>1573656911327</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1573656911327</updated>
</task>
<task id="LOCAL-00003" summary="Daily Commit&#10;Changes:&#10;- Implemented a button to reset the boxJSONData&#10;- Implemented the addition to the boxJSON">
<created>1580408186131</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1580408186131</updated>
</task>
<task id="LOCAL-00004" summary="Daily Commit&#10;Changes:&#10;- Implemented Date check for boxes&#10;- Introduced localUserData json for local meta data">
<created>1580491517972</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1580491517972</updated>
</task>
<task id="LOCAL-00005" summary="Daily Commit&#10;Changes:&#10;- Implemented more of the survey creation page including:&#10;0 A notification section&#10;0 A completed survey layout (with one specific bug, but everything else works great)">
<created>1581454623609</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1581454623609</updated>
</task>
<task id="LOCAL-00006" summary="Daily Commit&#10;Changes:&#10;- Created the &quot;template&quot; for all the experiment details that can be manipulated&#10;- Have defined a plan for the differences between the layout types and how to move forward">
<created>1581509178069</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1581509178069</updated>
</task>
<task id="LOCAL-00007" summary="Changes since last commit:&#10;- Made small changes to code to suppress typos or errors or warnings">
<created>1582048181350</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1582048181350</updated>
</task>
<task id="LOCAL-00008" summary="Changes since last commit:&#10;- Completed the survey response functionality&#10;- Started with the notification functionality, have a worked version in testing activity (dev screen)">
<created>1582668852049</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1582668852050</updated>
</task>
<task id="LOCAL-00009" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1582903224886</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1582903224887</updated>
</task>
<task id="LOCAL-00010" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1582905521139</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1582905521139</updated>
</task>
<task id="LOCAL-00011" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1583319473806</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1583319473806</updated>
</task>
<task id="LOCAL-00012" summary="Changes since last commit:&#10;- Colour changes for most pages">
<created>1584458255083</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1584458255083</updated>
</task>
<option name="localTasksCounter" value="13" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
<option name="RECENT_FILTERS">
<map>
<entry key="Branch">
<value>
<list />
</value>
</entry>
<entry key="User">
<value>
<list />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="Change to v0.0.1" />
<MESSAGE value="Change to v0.0.2" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented a button to reset the boxJSONData&#10;- Implemented the addition to the boxJSON" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented Date check for boxes&#10;- Introduced localUserData json for local meta data" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented more of the survey creation page including:&#10;0 A notification section&#10;0 A completed survey layout (with one specific bug, but everything else works great)" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Created the &quot;template&quot; for all the experiment details that can be manipulated&#10;- Have defined a plan for the differences between the layout types and how to move forward" />
<MESSAGE value="Changes since last commit:&#10;- Finished the newBox and ExperimentSurveyCreator pages&#10;- Full JSON production is completed so far for the boxes and experiments" />
<MESSAGE value="Changes since last commit:&#10;- Made small changes to code to suppress typos or errors or warnings" />
<MESSAGE value="Changes since last commit:&#10;- Completed the survey response functionality&#10;- Started with the notification functionality, have a worked version in testing activity (dev screen)" />
<MESSAGE value="Changes since last commit:&#10;- Fixing local index issue" />
<MESSAGE value="Changes since last commit:&#10;- Colour changes for most pages" />
<option name="LAST_COMMIT_MESSAGE" value="Changes since last commit:&#10;- Colour changes for most pages" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="com.yearthreeproject.xbframework" />
<option name="TOOL_WINDOW_LOG_LEVEL" value="verbose" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" />
</component>
<component name="ChangeListManager">
<list default="true" id="901156b8-4ed3-48c9-9feb-1fa598856dd4" name="Default Changelist" comment="Changes since last commit:&#10;- Finished progress page&#10;- Implemented Auth0 login and signup">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CodeInsightWorkspaceSettings">
<option name="optimizeImportsOnTheFly" value="true" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_2_API_29" />
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="ExternalProjectsManager">
<system id="GRADLE">
<state>
<task path="$PROJECT_DIR$">
<activation />
</task>
<task path="$PROJECT_DIR$/app">
<activation />
</task>
<projects_view>
<tree_state>
<expand />
<select />
</tree_state>
</projects_view>
</state>
</system>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="layoutResourceFile_vertical" />
<option value="Class" />
<option value="resourceFile" />
<option value="valueResourceFile" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1YGdFr4LLCXPCzaKdUL32gvMs2q" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="DeviceAndSnapshotComboBoxAction.selectedDevice" value="Pixel_2_API_29" />
<property name="DeviceAndSnapshotComboBoxAction.selectionTime" value="2020-02-11T20:50:41.427Z" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="android.sdk.path" value="$USER_HOME$/AppData/Local/Android/Sdk" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.17578948" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
<property name="settings.editor.selected.configurable" value="settings.github" />
</component>
<component name="PsdUISettings">
<option name="MODULE_TAB" value="Default Config" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\" />
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\drawable-xxhdpi" />
<recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\raw" />
</key>
<key name="CreateClassDialog.RecentsKey">
<recent name="com.yearthreeproject.xbframework" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration default="true" type="AndroidJUnit" factoryName="Android JUnit">
<option name="TEST_OBJECT" value="class" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="app" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="app" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sample Java Methods" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="901156b8-4ed3-48c9-9feb-1fa598856dd4" name="Default Changelist" comment="" />
<created>1572372213329</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1572372213329</updated>
</task>
<task id="LOCAL-00001" summary="Change to v0.0.1">
<created>1573421262618</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1573421262618</updated>
</task>
<task id="LOCAL-00002" summary="Change to v0.0.2">
<created>1573656911327</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1573656911327</updated>
</task>
<task id="LOCAL-00003" summary="Daily Commit&#10;Changes:&#10;- Implemented a button to reset the boxJSONData&#10;- Implemented the addition to the boxJSON">
<created>1580408186131</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1580408186131</updated>
</task>
<task id="LOCAL-00004" summary="Daily Commit&#10;Changes:&#10;- Implemented Date check for boxes&#10;- Introduced localUserData json for local meta data">
<created>1580491517972</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1580491517972</updated>
</task>
<task id="LOCAL-00005" summary="Daily Commit&#10;Changes:&#10;- Implemented more of the survey creation page including:&#10;0 A notification section&#10;0 A completed survey layout (with one specific bug, but everything else works great)">
<created>1581454623609</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1581454623609</updated>
</task>
<task id="LOCAL-00006" summary="Daily Commit&#10;Changes:&#10;- Created the &quot;template&quot; for all the experiment details that can be manipulated&#10;- Have defined a plan for the differences between the layout types and how to move forward">
<created>1581509178069</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1581509178069</updated>
</task>
<task id="LOCAL-00007" summary="Changes since last commit:&#10;- Made small changes to code to suppress typos or errors or warnings">
<created>1582048181350</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1582048181350</updated>
</task>
<task id="LOCAL-00008" summary="Changes since last commit:&#10;- Completed the survey response functionality&#10;- Started with the notification functionality, have a worked version in testing activity (dev screen)">
<created>1582668852049</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1582668852050</updated>
</task>
<task id="LOCAL-00009" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1582903224886</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1582903224887</updated>
</task>
<task id="LOCAL-00010" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1582905521139</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1582905521139</updated>
</task>
<task id="LOCAL-00011" summary="Changes since last commit:&#10;- Fixing local index issue">
<created>1583319473806</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1583319473806</updated>
</task>
<task id="LOCAL-00012" summary="Changes since last commit:&#10;- Colour changes for most pages">
<created>1584458255083</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1584458255083</updated>
</task>
<task id="LOCAL-00013" summary="Changes since last commit:&#10;- Finished progress page&#10;- Implemented Auth0 login and signup">
<created>1585326733562</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1585326733562</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
<option name="RECENT_FILTERS">
<map>
<entry key="Branch">
<value>
<list />
</value>
</entry>
<entry key="User">
<value>
<list />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="Change to v0.0.1" />
<MESSAGE value="Change to v0.0.2" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented a button to reset the boxJSONData&#10;- Implemented the addition to the boxJSON" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented Date check for boxes&#10;- Introduced localUserData json for local meta data" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Implemented more of the survey creation page including:&#10;0 A notification section&#10;0 A completed survey layout (with one specific bug, but everything else works great)" />
<MESSAGE value="Daily Commit&#10;Changes:&#10;- Created the &quot;template&quot; for all the experiment details that can be manipulated&#10;- Have defined a plan for the differences between the layout types and how to move forward" />
<MESSAGE value="Changes since last commit:&#10;- Finished the newBox and ExperimentSurveyCreator pages&#10;- Full JSON production is completed so far for the boxes and experiments" />
<MESSAGE value="Changes since last commit:&#10;- Made small changes to code to suppress typos or errors or warnings" />
<MESSAGE value="Changes since last commit:&#10;- Completed the survey response functionality&#10;- Started with the notification functionality, have a worked version in testing activity (dev screen)" />
<MESSAGE value="Changes since last commit:&#10;- Fixing local index issue" />
<MESSAGE value="Changes since last commit:&#10;- Colour changes for most pages" />
<MESSAGE value="Changes since last commit:&#10;- Finished progress page&#10;- Implemented Auth0 login and signup" />
<option name="LAST_COMMIT_MESSAGE" value="Changes since last commit:&#10;- Finished progress page&#10;- Implemented Auth0 login and signup" />
</component>
</project>
\ No newline at end of file
...@@ -2,16 +2,19 @@ apply plugin: 'com.android.application' ...@@ -2,16 +2,19 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.2" buildToolsVersion "29.0.3"
defaultConfig { defaultConfig {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "com.yearthreeproject.xbframework" applicationId "com.yearthreeproject.xbframework"
minSdkVersion 16 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "@string/auth0_scheme"] }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
} }
buildTypes { buildTypes {
release { release {
...@@ -29,13 +32,12 @@ dependencies { ...@@ -29,13 +32,12 @@ dependencies {
//noinspection GradleCompatible //noinspection GradleCompatible
implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.android.material:material:1.1.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.0' api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'com.jjoe64:graphview:4.2.2' implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.github.sundeepk:compact-calendar-view:3.0.0' implementation 'com.github.sundeepk:compact-calendar-view:3.0.0'
implementation 'com.auth0.android:auth0:1.22.1' implementation 'org.mongodb:stitch-android-sdk:4.1.0'
implementation 'com.auth0.android:lock:2.7.0'
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
tools:ignore="GoogleAppIndexingWarning"> tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity" <activity android:name=".MainActivity"
tools:overrideLibrary="com.mongodb.stitch.android.services.mongodb.remote"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
...@@ -25,13 +26,6 @@ ...@@ -25,13 +26,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name="com.auth0.android.lock.LockActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/Lock.Theme"/>
<activity <activity
android:name=".AboutActivity" android:name=".AboutActivity"
android:label="About" android:label="About"
......
package com.yearthreeproject.xbframework; package com.yearthreeproject.xbframework;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -18,14 +16,14 @@ import androidx.annotation.RequiresApi; ...@@ -18,14 +16,14 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Objects; import java.util.Objects;
import static android.util.Log.d;
public class BoxesActivity extends AppCompatActivity { public class BoxesActivity extends AppCompatActivity {
@Override @Override
...@@ -34,23 +32,9 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -34,23 +32,9 @@ public class BoxesActivity extends AppCompatActivity {
return true; return true;
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem createBox = menu.add("Create New Box!");
createBox.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
startActivity(new Intent(BoxesActivity.this, NewBox.class));
return false;
}
});
return true;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
// Ordinary setup of UI for general app purposes
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_boxes); setContentView(R.layout.activity_boxes);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
...@@ -64,8 +48,9 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -64,8 +48,9 @@ public class BoxesActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);
FloatingActionButton createBox = findViewById(R.id.CreateNewBoxFab);
createBox.setOnClickListener(v -> startActivity(new Intent(BoxesActivity.this, NewBox.class)));
// JSON loading from local directory, could be implemented to stream from online
loadAndDisplayJSON(); loadAndDisplayJSON();
} }
...@@ -73,20 +58,16 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -73,20 +58,16 @@ public class BoxesActivity extends AppCompatActivity {
private void loadAndDisplayJSON() { private void loadAndDisplayJSON() {
LinearLayout inFiveLayout = findViewById(R.id.BoxesInFiveLayout); LinearLayout inFiveLayout = findViewById(R.id.BoxesInFiveLayout);
JSONArray boxes; JSONArray boxes;
final String[] inFive = {"Move", "Eat", "Engage", "Cogitate", "Sleep"}; final String[] inFive = getResources().getStringArray(R.array.meecs);
// Try, in order to avoid errors in compilation and catastrophic errors
try { try {
d("dbg_boxesParse", ProjectMacros.readFile(this, "boxData.json"));
boxes = new JSONArray(ProjectMacros.readFile(this, "boxData.json")); boxes = new JSONArray(ProjectMacros.readFile(this, "boxData.json"));
LinearLayout[] inFiveLayoutArray = new LinearLayout[5]; LinearLayout[] inFiveLayoutArray = new LinearLayout[inFive.length];
LinearLayout[] inFiveAvailableBoxes = new LinearLayout[boxes.length()]; LinearLayout[] inFiveAvailableBoxes = new LinearLayout[boxes.length()];
for (int i = 0; i < inFive.length; i++) { for (int i = 0; i < inFive.length-1; i++) {
inFiveLayoutArray[i] = new LinearLayout(this); inFiveLayoutArray[i] = new LinearLayout(this);
TextView inFiveTitle = new TextView(this); TextView inFiveTitle = new TextView(this);
...@@ -94,7 +75,9 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -94,7 +75,9 @@ public class BoxesActivity extends AppCompatActivity {
inFiveTitle.setText(inFive[i]); inFiveTitle.setText(inFive[i]);
inFiveTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36); inFiveTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
inFiveTitle.setPadding(0, 8, 0, 0); inFiveTitle.setPadding(0, 8, 0, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
inFiveTitle.setTextColor(getColor(R.color.colorPrimary)); inFiveTitle.setTextColor(getColor(R.color.colorPrimary));
}
inFiveLayoutArray[i].setOrientation(LinearLayout.VERTICAL); inFiveLayoutArray[i].setOrientation(LinearLayout.VERTICAL);
inFiveLayoutArray[i].addView(inFiveTitle); inFiveLayoutArray[i].addView(inFiveTitle);
...@@ -102,7 +85,9 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -102,7 +85,9 @@ public class BoxesActivity extends AppCompatActivity {
View hr = new View(this); View hr = new View(this);
ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4);
hr.setLayoutParams(hrLayoutParams); hr.setLayoutParams(hrLayoutParams);
hr.setBackgroundColor(Color.parseColor("#587B7F")); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
hr.setBackgroundColor(getColor(R.color.colorPrimary));
}
inFiveLayoutArray[i].addView(hr); inFiveLayoutArray[i].addView(hr);
...@@ -121,10 +106,14 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -121,10 +106,14 @@ public class BoxesActivity extends AppCompatActivity {
TextView titleOfBox = new TextView(this); TextView titleOfBox = new TextView(this);
titleOfBox.setText(box.getString("Name")); titleOfBox.setText(box.getString("Name"));
titleOfBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28); titleOfBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
titleOfBox.setTextColor(getColor(R.color.colorPrimary)); titleOfBox.setTextColor(getColor(R.color.colorPrimary));
}
TextView descriptionOfBox = new TextView(this); TextView descriptionOfBox = new TextView(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
descriptionOfBox.setTextColor(getColor(R.color.colorPrimary)); descriptionOfBox.setTextColor(getColor(R.color.colorPrimary));
}
descriptionOfBox.setText(box.getString("Blurb")); descriptionOfBox.setText(box.getString("Blurb"));
...@@ -132,35 +121,24 @@ public class BoxesActivity extends AppCompatActivity { ...@@ -132,35 +121,24 @@ public class BoxesActivity extends AppCompatActivity {
boxLayout.addView(descriptionOfBox); boxLayout.addView(descriptionOfBox);
ImageView boxLogo; ImageView boxLogo;
if (!box.getString("Image").equals("null")) { if (box.getString("Image").equals("null")) {
boxLogo = new ImageView(this); boxLogo = new ImageView(this);
boxLogo.setImageResource(R.mipmap.ic_launcher); boxLogo.setImageResource(R.mipmap.ic_launcher);
inFiveAvailableBoxes[j].addView(boxLogo); inFiveAvailableBoxes[j].addView(boxLogo);
} else {
boxLogo = new ImageView(this);
boxLogo.setImageURI(Uri.parse(box.getString("Image")));
inFiveAvailableBoxes[j].addView(boxLogo);
} }
inFiveAvailableBoxes[j].addView(boxLayout); inFiveAvailableBoxes[j].addView(boxLayout);
inFiveAvailableBoxes[j].setId(j); inFiveAvailableBoxes[j].setId(j);
inFiveAvailableBoxes[j].setOnClickListener(new View.OnClickListener() { inFiveAvailableBoxes[j].setOnClickListener(v -> {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onClick(View v) {
try {
// TODO: complete this, and also improve the notification generation side by making sure the full time is 5 characters long, and has a full title
boolean locked = box.getBoolean("Locked");
JSONObject localData = new JSONObject(ProjectMacros.readFile(BoxesActivity.this, "localUserData.json"));
if (!locked) {
Intent openPage = new Intent(BoxesActivity.this, ExperimentActivity.class); Intent openPage = new Intent(BoxesActivity.this, ExperimentActivity.class);
openPage.putExtra("JSON", box.toString()); openPage.putExtra("JSON", box.toString());
startActivity(openPage); startActivity(openPage);
finish(); finish();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}); });
inFiveLayoutArray[i].addView(inFiveAvailableBoxes[j]); inFiveLayoutArray[i].addView(inFiveAvailableBoxes[j]);
} }
......
package com.yearthreeproject.xbframework; package com.yearthreeproject.xbframework;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.icu.text.SimpleDateFormat; import android.icu.text.SimpleDateFormat;
import android.os.Build; import android.os.Build;
...@@ -17,14 +20,19 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -17,14 +20,19 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mongodb.stitch.android.core.Stitch;
import com.mongodb.stitch.android.core.StitchAppClient;
import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoClient;
import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoCollection;
import com.mongodb.stitch.core.services.mongodb.remote.RemoteUpdateOptions;
import org.bson.Document;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Objects;
import static android.util.Log.d; import static android.util.Log.d;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
...@@ -49,7 +57,7 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -49,7 +57,7 @@ public class ExperimentActivity extends AppCompatActivity {
toolbar.setNestedScrollingEnabled(false); toolbar.setNestedScrollingEnabled(false);
} }
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher); getSupportActionBar().setLogo(R.mipmap.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true); getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
...@@ -71,7 +79,9 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -71,7 +79,9 @@ public class ExperimentActivity extends AppCompatActivity {
*/ */
TextView boxDescription = new TextView(this); TextView boxDescription = new TextView(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
boxDescription.setTextColor(getColor(R.color.colorPrimary)); boxDescription.setTextColor(getColor(R.color.colorPrimary));
}
boxDescription.setText(Html.fromHtml(boxJSON.getString("Description") + "<font color=red> " + boxJSON.getString("WarningText") + "</font color>")); boxDescription.setText(Html.fromHtml(boxJSON.getString("Description") + "<font color=red> " + boxJSON.getString("WarningText") + "</font color>"));
...@@ -89,13 +99,17 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -89,13 +99,17 @@ public class ExperimentActivity extends AppCompatActivity {
View hr = new View(this); View hr = new View(this);
ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4);
hr.setLayoutParams(hrLayoutParams); hr.setLayoutParams(hrLayoutParams);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
hr.setBackgroundColor(getColor(R.color.colorPrimary)); hr.setBackgroundColor(getColor(R.color.colorPrimary));
}
hr.setPadding(0, 0, 0, 16); hr.setPadding(0, 0, 0, 16);
TextView experimentGroupName = new TextView(this); TextView experimentGroupName = new TextView(this);
experimentGroupName.setText(experimentsJSONArray.getJSONObject(i).getString("Group")); experimentGroupName.setText(experimentsJSONArray.getJSONObject(i).getString("Group"));
experimentGroupName.setPadding(0, 8, 0, 8); experimentGroupName.setPadding(0, 8, 0, 8);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
experimentGroupName.setTextColor(getColor(R.color.colorPrimary)); experimentGroupName.setTextColor(getColor(R.color.colorPrimary));
}
experimentInfoLayout.addView(hr); experimentInfoLayout.addView(hr);
...@@ -105,20 +119,23 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -105,20 +119,23 @@ public class ExperimentActivity extends AppCompatActivity {
for (int j = 0; j < experimentChoices.length(); j++) { for (int j = 0; j < experimentChoices.length(); j++) {
RadioButton experimentRadioButton = new RadioButton(this); RadioButton experimentRadioButton = new RadioButton(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
experimentRadioButton.setButtonTintList(new ColorStateList(new int[][]{new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled}}, new int[]{Color.BLACK, getColor(R.color.colorPrimary)}));
}
JSONObject experimentData = experimentChoices.getJSONObject(j); JSONObject experimentData = experimentChoices.getJSONObject(j);
experimentRadioButton.setId(radioButtonUniqueId); experimentRadioButton.setId(radioButtonUniqueId);
experimentRadioButton.setText(experimentData.getString("Title")); experimentRadioButton.setText(experimentData.getString("Title"));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
experimentRadioButton.setTextColor(getColor(R.color.colorPrimary)); experimentRadioButton.setTextColor(getColor(R.color.colorPrimary));
experimentRadioButton.setOnClickListener(new View.OnClickListener() { }
public void onClick(View v) { experimentRadioButton.setOnClickListener(v -> {
for (int x = 0; x < experimentsRadioButtonArray.size(); x++) { for (int x = 0; x < experimentsRadioButtonArray.size(); x++) {
if (x != v.getId()) if (x != v.getId())
experimentsRadioButtonArray.get(x).setChecked(false); experimentsRadioButtonArray.get(x).setChecked(false);
else experimentsRadioButtonArray.get(x).setChecked(true); else experimentsRadioButtonArray.get(x).setChecked(true);
} }
}
}); });
experimentsRadioButtonArray.add(experimentRadioButton); experimentsRadioButtonArray.add(experimentRadioButton);
...@@ -132,9 +149,7 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -132,9 +149,7 @@ public class ExperimentActivity extends AppCompatActivity {
} }
FloatingActionButton fab = findViewById(R.id.experimentFAB); FloatingActionButton fab = findViewById(R.id.experimentFAB);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(v -> {
@RequiresApi(api = Build.VERSION_CODES.N)
public void onClick(View v) {
for (int x = 0; x < experimentsRadioButtonArray.size(); x++) for (int x = 0; x < experimentsRadioButtonArray.size(); x++)
if (experimentsRadioButtonArray.get(x).isChecked()) { if (experimentsRadioButtonArray.get(x).isChecked()) {
int pseudoCount = 0; int pseudoCount = 0;
...@@ -148,20 +163,45 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -148,20 +163,45 @@ public class ExperimentActivity extends AppCompatActivity {
experimentGroup++; experimentGroup++;
} else { } else {
JSONObject editJSON = new JSONObject(ProjectMacros.readFile(ExperimentActivity.this, "localUserData.json")); JSONObject editJSON = new JSONObject(ProjectMacros.readFile(ExperimentActivity.this, "localUserData.json"));
editJSON.put("lockedExperiment", boxJSON.getJSONArray("Experiments").getJSONObject(experimentGroup).getJSONArray("Options").getJSONObject(x - pseudoCount)); editJSON.put("lockedExperiment", boxJSON.getJSONArray("Experiments").getJSONObject(experimentGroup).getJSONArray("Options").getJSONObject(x - pseudoCount).put("Type", boxJSON.getString("Group")));
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat simpleDateFormat = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
calendar.add(Calendar.DATE, 5); calendar.add(Calendar.DATE, 5);
String dateUntil = simpleDateFormat.format(calendar.getTime()); String dateUntil = simpleDateFormat.format(calendar.getTime());
editJSON.put("dateUntil", dateUntil); editJSON.put("dateUntil", dateUntil);
}
editJSON.put("locked", true); editJSON.put("locked", true);
ProjectMacros.saveFile(ExperimentActivity.this, "localUserData.json", editJSON.toString()); ProjectMacros.saveFile(ExperimentActivity.this, "localUserData.json", editJSON.toString());
final StitchAppClient client;
if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){
client = Stitch.getDefaultAppClient();
} else {
client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id));
}
final RemoteMongoClient mongoClient = client.getServiceClient(RemoteMongoClient.factory, "XBF");
final RemoteMongoCollection<Document> coll = mongoClient.getDatabase("IPServer").getCollection("UserData");
SharedPreferences savedSettings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE);
client.getAuth().addAuthListener(auth -> {
if (auth.isLoggedIn()) {
coll.updateOne(
new Document("owner_id", auth.getUser().getId()),
Document.parse(editJSON.toString())
.append("owner_id", auth.getUser().getId()),
new RemoteUpdateOptions().upsert(true)).addOnCompleteListener(task1->{
d("dbg_was_succesful", String.valueOf(task1.isSuccessful()));
d("dbg_storedJSON", editJSON.toString()); d("dbg_storedJSON", editJSON.toString());
finish(); finish();
});
}
});
} }
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -169,7 +209,6 @@ public class ExperimentActivity extends AppCompatActivity { ...@@ -169,7 +209,6 @@ public class ExperimentActivity extends AppCompatActivity {
} }
} }
}
}); });
} }
} }
package com.yearthreeproject.xbframework; package com.yearthreeproject.xbframework;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.util.Log;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.auth0.android.Auth0; import com.mongodb.DBObject;
import com.auth0.android.authentication.AuthenticationAPIClient; import com.mongodb.stitch.android.core.Stitch;
import com.auth0.android.authentication.AuthenticationException; import com.mongodb.stitch.android.core.StitchAppClient;
import com.auth0.android.callback.BaseCallback; import com.mongodb.stitch.android.core.auth.providers.userpassword.UserPasswordAuthProviderClient;
import com.auth0.android.lock.AuthenticationCallback; import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoClient;
import com.auth0.android.lock.Lock; import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoCollection;
import com.auth0.android.lock.utils.LockException; import com.mongodb.stitch.core.auth.providers.userpassword.UserPasswordCredential;
import com.auth0.android.result.Credentials; import com.mongodb.stitch.core.services.mongodb.remote.RemoteUpdateOptions;
import org.bson.Document;
import org.json.JSONObject;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import static android.util.Log.d; import static android.util.Log.d;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
private Toast messageToast;
private Auth0 auth0;
private Lock lock;
@Override @Override
public boolean onSupportNavigateUp() { public boolean onSupportNavigateUp() {
...@@ -35,63 +44,127 @@ public class LoginActivity extends AppCompatActivity { ...@@ -35,63 +44,127 @@ public class LoginActivity extends AppCompatActivity {
return true; return true;
} }
@Override
public void onBackPressed() {
ProjectMacros.showToast(messageToast, this, "Cannot leave login page without logging in!");
}
@Override
protected void onResume(){
super.onResume();
SharedPreferences savedSettings = LoginActivity.this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE);
if(savedSettings.getBoolean("loggedIn", false)) {
finish();
}
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
SharedPreferences savedSettings = LoginActivity.this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE);
if(savedSettings.getBoolean("loggedIn", false)){
finish();
}
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher); getSupportActionBar().setLogo(R.mipmap.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true); getSupportActionBar().setDisplayUseLogoEnabled(true);
auth0 = new Auth0(getString(R.string.com_auth0_client_id), getString(R.string.com_auth0_domain)); messageToast = new Toast(this);
auth0.setOIDCConformant(true);
lock = Lock.newBuilder(auth0, cb).build(this);
final EditText email = findViewById(R.id.EmailEditText); final EditText email = findViewById(R.id.EmailEditText);
final EditText password = findViewById(R.id.PasswordEditText); final EditText password = findViewById(R.id.PasswordEditText);
final AuthenticationAPIClient authentication = new AuthenticationAPIClient(auth0); String hashedPassword = null;
try {
MessageDigest md = MessageDigest.getInstance( "SHA-512" );
md.update(password.getText().toString().getBytes());
byte messageDigested[] = md.digest();
Button submitLoginButton = findViewById(R.id.LoginSubmitButton); StringBuffer hexString = new StringBuffer();
submitLoginButton.setOnClickListener(new View.OnClickListener() { for (int i=0; i<messageDigested.length; i++) hexString.append(Integer.toHexString(0xFF & messageDigested[i]));
public void onClick(View v) { hashedPassword = hexString.toString();
authentication
.login(email.getText().toString(), password.getText().toString(), "Username-Password-Authentication") } catch (NoSuchAlgorithmException e) {
.start(new BaseCallback<Credentials, AuthenticationException>() { e.printStackTrace();
@Override
public void onSuccess(Credentials payload) {
d("dbg_success", payload.getIdToken());
} }
@Override Button submitLoginButton = findViewById(R.id.LoginSubmitButton);
public void onFailure(AuthenticationException error) { String finalHashedPassword = hashedPassword;
d("dbg_failure", error.getMessage()); submitLoginButton.setOnClickListener(v -> {
final StitchAppClient client;
if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){
client = Stitch.getDefaultAppClient();
} else {
client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id));
} }
}); final RemoteMongoClient mongoClient = client.getServiceClient(RemoteMongoClient.factory, "XBF");
//startActivity(lock.newIntent(LoginActivity.this)); final RemoteMongoCollection<Document> coll = mongoClient.getDatabase("IPServer").getCollection("UserData");
client.getAuth().loginWithCredential(new UserPasswordCredential(email.getText().toString(), finalHashedPassword)).continueWithTask(task -> {
if (!task.isSuccessful()) {
Log.e("STITCH", "Login failed!");
client.getAuth().getProviderClient(UserPasswordAuthProviderClient.factory).registerWithEmail(email.getText().toString(), finalHashedPassword);
throw task.getException();
} }
List<Document> docs = new ArrayList<>();
return coll.find(new Document("owner_id", client.getAuth().getUser().getId())).into(docs);
}).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
SharedPreferences.Editor savedSettingsEditor = savedSettings.edit();
savedSettingsEditor.putBoolean("loggedIn", true);
savedSettingsEditor.apply();
// Create users object if doesnt already exist
if(task.getResult().size() == 0){
d("dbg_size", String.valueOf(task.getResult().size()));
coll.updateOne(new Document("owner_id", client.getAuth().getUser().getId()),
new Document("owner_id", client.getAuth().getUser().getId())
.append("dateUntil", null)
.append("locked", false)
.append("lockedExperiment", Document.parse(new JSONObject().toString()))
.append("journal", new ArrayList<DBObject>())
.append("archivedExperimentData", new ArrayList<DBObject>()),
new RemoteUpdateOptions().upsert(true)).addOnCompleteListener(task2->{
if(task2.isSuccessful()){
d("dbg_uploaded", "true");
} else {
task2.getException().printStackTrace();
}
finish();
}); });
} else {
finish();
} }
} else{
private AuthenticationCallback cb = new AuthenticationCallback() { Log.e("STITCH", "Error: " + task.getException().toString());
@Override task.getException().printStackTrace();
public void onError(LockException error) { finish();
d("dbg_err", "err");
} }
});
});
@Override
public void onAuthentication(Credentials credentials) {
d("dbg_success", "success");
}
@Override Button submitRegisterButton = new Button(this);
public void onCanceled() { submitRegisterButton.setText("Register");
d("dbg_cancelled", "cancelled"); LinearLayout parent = (LinearLayout) submitLoginButton.getParent();
parent.addView(submitRegisterButton);
submitRegisterButton.setOnClickListener(view -> {
final StitchAppClient client;
if (Stitch.hasAppClient(getString(R.string.mongo_stitch_id))) {
client = Stitch.getDefaultAppClient();
} else {
client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id));
}
client.getAuth().getProviderClient(UserPasswordAuthProviderClient.factory).registerWithEmail(email.getText().toString(), finalHashedPassword).addOnCompleteListener(task -> {
ProjectMacros.showToast(messageToast, LoginActivity.this, "You have successfully registered!");
});
});
} }
};
} }
package com.yearthreeproject.xbframework; package com.yearthreeproject.xbframework;
import android.Manifest; import android.Manifest;
import android.content.DialogInterface; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
...@@ -33,6 +33,7 @@ import androidx.appcompat.widget.Toolbar; ...@@ -33,6 +33,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.theartofdev.edmodo.cropper.CropImage; import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView; import com.theartofdev.edmodo.cropper.CropImageView;
...@@ -96,6 +97,7 @@ public class NewBox extends AppCompatActivity { ...@@ -96,6 +97,7 @@ public class NewBox extends AppCompatActivity {
final Spinner inFiveSpinner = findViewById(R.id.MEECSSpinner); final Spinner inFiveSpinner = findViewById(R.id.MEECSSpinner);
ArrayAdapter<CharSequence> inFiveAdapter = ArrayAdapter.createFromResource(this, R.array.meecs, android.R.layout.simple_spinner_dropdown_item); ArrayAdapter<CharSequence> inFiveAdapter = ArrayAdapter.createFromResource(this, R.array.meecs, android.R.layout.simple_spinner_dropdown_item);
inFiveSpinner.setAdapter(inFiveAdapter); inFiveSpinner.setAdapter(inFiveAdapter);
inFiveSpinner.setSelection(inFiveAdapter.getPosition(inFiveValue));
inFiveSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { inFiveSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
...@@ -108,12 +110,7 @@ public class NewBox extends AppCompatActivity { ...@@ -108,12 +110,7 @@ public class NewBox extends AppCompatActivity {
} }
}); });
uploadImageButton.setMaxHeight(uploadImageButton.getHeight()); uploadImageButton.setMaxHeight(uploadImageButton.getHeight());
uploadImageButton.setOnClickListener(new View.OnClickListener() { uploadImageButton.setOnClickListener(v -> imagePermissionCheckFunction());
@Override
public void onClick(View v) {
imagePermissionCheckFunction();
}
});
final LinearLayout scrollLayout = findViewById(R.id.InputDataScrollableLayout); final LinearLayout scrollLayout = findViewById(R.id.InputDataScrollableLayout);
...@@ -125,30 +122,21 @@ public class NewBox extends AppCompatActivity { ...@@ -125,30 +122,21 @@ public class NewBox extends AppCompatActivity {
scrollLayout.addView(addNewGroupButton); scrollLayout.addView(addNewGroupButton);
addNewGroupButton.setOnClickListener(new View.OnClickListener() { addNewGroupButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
scrollLayout.removeView(v); scrollLayout.removeView(v);
scrollLayout.addView(addGroupFunction(++globalGroupIndex)); scrollLayout.addView(addGroupFunction(++globalGroupIndex));
scrollLayout.addView(v); scrollLayout.addView(v);
d("dbg_numOfGroupTitles", String.valueOf(groupTitlesArray.size())); d("dbg_numOfGroupTitles", String.valueOf(groupTitlesArray.size()));
}
}); });
Button submit = findViewById(R.id.NewBoxSubmitButton); FloatingActionButton submitFAB = findViewById(R.id.NewBoxSubmitFAB);
submit.setOnClickListener(new View.OnClickListener() { submitFAB.setOnClickListener(v -> submitNewBoxFunction());
@Override
public void onClick(View v) {
submitNewBoxFunction();
}
});
} }
private void submitNewBoxFunction() { private void submitNewBoxFunction() {
boolean completedInfo = true; boolean completedInfo = true;
String toastText = "Need to fill out all the information to be able to submit box for review"; String toastText = "Need to fill out all the information to be able to submit box for review";
// Checks for completed data
for (int i = 0; i < groupTitlesArray.size(); i++) { for (int i = 0; i < groupTitlesArray.size(); i++) {
if (groupTitlesArray.get(i).getText().toString().matches("")) { if (groupTitlesArray.get(i).getText().toString().matches("")) {
completedInfo = false; completedInfo = false;
...@@ -212,7 +200,7 @@ public class NewBox extends AppCompatActivity { ...@@ -212,7 +200,7 @@ public class NewBox extends AppCompatActivity {
tempEditTextForStringRetrieval = findViewById(R.id.BlurbEditText); tempEditTextForStringRetrieval = findViewById(R.id.BlurbEditText);
box.put("Blurb", tempEditTextForStringRetrieval.getText().toString()); box.put("Blurb", tempEditTextForStringRetrieval.getText().toString());
box.put("Locked", false); // TODO: change back to true when requesting a new box box.put("Approved", false);
if (imageUploaded) box.put("Image", imageUploadResultUri); if (imageUploaded) box.put("Image", imageUploadResultUri);
else box.put("Image", JSONObject.NULL); else box.put("Image", JSONObject.NULL);
...@@ -248,7 +236,7 @@ public class NewBox extends AppCompatActivity { ...@@ -248,7 +236,7 @@ public class NewBox extends AppCompatActivity {
openPage.putExtra("JSON", box.toString()); openPage.putExtra("JSON", box.toString());
openPage.putExtra("ExperimentIndex", 0); openPage.putExtra("ExperimentIndex", 0);
openPage.putExtra("GroupIndex", 0); openPage.putExtra("GroupIndex", 0);
d("dbg_json", box.toString());
startActivity(openPage); startActivity(openPage);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -270,14 +258,11 @@ public class NewBox extends AppCompatActivity { ...@@ -270,14 +258,11 @@ public class NewBox extends AppCompatActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this); AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this);
builder.setTitle("Permission Required") builder.setTitle("Permission Required")
.setMessage("Permission to device storage is required for image upload.") .setMessage("Permission to device storage is required for image upload.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { .setPositiveButton("Ok", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package", getPackageName(), null)); intent.setData(Uri.fromParts("package", getPackageName(), null));
startActivityForResult(intent, 5); startActivityForResult(intent, 5);
}
}).setNegativeButton("Cancel", null).show(); }).setNegativeButton("Cancel", null).show();
} else { } else {
...@@ -291,6 +276,7 @@ public class NewBox extends AppCompatActivity { ...@@ -291,6 +276,7 @@ public class NewBox extends AppCompatActivity {
} }
} }
@SuppressLint("ResourceType")
private LinearLayout addGroupFunction(final int localGroupIndex) { private LinearLayout addGroupFunction(final int localGroupIndex) {
final LinearLayout linearGroupLayout = new LinearLayout(this); final LinearLayout linearGroupLayout = new LinearLayout(this);
linearGroupLayout.setOrientation(LinearLayout.VERTICAL); linearGroupLayout.setOrientation(LinearLayout.VERTICAL);
...@@ -346,48 +332,40 @@ public class NewBox extends AppCompatActivity { ...@@ -346,48 +332,40 @@ public class NewBox extends AppCompatActivity {
relativeGroupLayout.addView(deleteGroupButton, deleteGroupButtonAlignment); relativeGroupLayout.addView(deleteGroupButton, deleteGroupButtonAlignment);
groupTitlesArray.add(titleEditText); groupTitlesArray.add(titleEditText);
experimentTitlesArray.add(new ArrayList<EditText>()); experimentTitlesArray.add(new ArrayList<>());
experimentDescriptionsArray.add(new ArrayList<EditText>()); experimentDescriptionsArray.add(new ArrayList<>());
experimentInstructionsArray.add(new ArrayList<EditText>()); experimentInstructionsArray.add(new ArrayList<>());
addExperimentToGroupButton.setOnClickListener(new View.OnClickListener() { addExperimentToGroupButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
LinearLayout parent = (LinearLayout) v.getParent(); LinearLayout parent = (LinearLayout) v.getParent();
parent.removeView(v); parent.removeView(v);
linearGroupLayout.addView(addExperimentFunction(localGroupIndex)); linearGroupLayout.addView(addExperimentFunction(localGroupIndex));
parent.addView(v); parent.addView(v);
}
}); });
deleteGroupButton.setOnClickListener(new View.OnClickListener() { deleteGroupButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
AlertDialog.Builder al = new AlertDialog.Builder(NewBox.this); AlertDialog.Builder al = new AlertDialog.Builder(NewBox.this);
al.setTitle("Are you sure?") al.setTitle("Are you sure?")
.setMessage("Are you sure you want to delete this group?") .setMessage("Are you sure you want to delete this group?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() { .setPositiveButton("Yes", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
linearGroupLayout.removeAllViews(); linearGroupLayout.removeAllViews();
groupTitlesArray.remove(titleEditText); groupTitlesArray.remove(titleEditText);
experimentTitlesArray.remove(localGroupIndex); experimentTitlesArray.remove(localGroupIndex);
experimentDescriptionsArray.remove(localGroupIndex); experimentDescriptionsArray.remove(localGroupIndex);
experimentInstructionsArray.remove(localGroupIndex); experimentInstructionsArray.remove(localGroupIndex);
globalGroupIndex--; globalGroupIndex--;
}
}).setNegativeButton("No", null) }).setNegativeButton("No", null)
.show(); .show();
}
}); });
linearGroupLayout.addView(relativeGroupLayout); linearGroupLayout.addView(relativeGroupLayout);
linearGroupLayout.addView(addExperimentToGroupButton); linearGroupLayout.addView(addExperimentToGroupButton);
linearGroupLayout.addView(ProjectMacros.newHR(this, 4, "#888888")); linearGroupLayout.addView(ProjectMacros.newHR(this, 4, getString(R.color.colorPrimary)));
return linearGroupLayout; return linearGroupLayout;
} }
@SuppressLint("ResourceType")
private RelativeLayout addExperimentFunction(final int localGroupIndex) { private RelativeLayout addExperimentFunction(final int localGroupIndex) {
final RelativeLayout experimentRelativeLayout = new RelativeLayout(this); final RelativeLayout experimentRelativeLayout = new RelativeLayout(this);
...@@ -467,32 +445,24 @@ public class NewBox extends AppCompatActivity { ...@@ -467,32 +445,24 @@ public class NewBox extends AppCompatActivity {
experimentRelativeLayout.addView(experimentDescriptionTextView, experimentDescriptionTextViewAlignment); experimentRelativeLayout.addView(experimentDescriptionTextView, experimentDescriptionTextViewAlignment);
experimentRelativeLayout.addView(experimentInstructionsEditText, experimentInstructionsEditTextAlignment); experimentRelativeLayout.addView(experimentInstructionsEditText, experimentInstructionsEditTextAlignment);
experimentRelativeLayout.addView(experimentInstructionsTextView, experimentInstructionsTextViewAlignment); experimentRelativeLayout.addView(experimentInstructionsTextView, experimentInstructionsTextViewAlignment);
experimentRelativeLayout.addView(ProjectMacros.newHR(this, 2, "#666666"), localHRAlignment); experimentRelativeLayout.addView(ProjectMacros.newHR(this, 2, getString(R.color.colorPrimary)), localHRAlignment);
Button deleteExperimentButton = new Button(NewBox.this); Button deleteExperimentButton = new Button(NewBox.this);
textViewTempText = "x"; textViewTempText = "x";
deleteExperimentButton.setText(textViewTempText); deleteExperimentButton.setText(textViewTempText);
deleteExperimentButton.setOnClickListener(new View.OnClickListener() { deleteExperimentButton.setOnClickListener(v -> {
@Override
public void onClick(View v) {
ViewGroup deleteExperimentButtonParent = (ViewGroup) v.getParent(); ViewGroup deleteExperimentButtonParent = (ViewGroup) v.getParent();
experimentTitlesArray.get(localGroupIndex).remove(experimentTitleEditText); experimentTitlesArray.get(localGroupIndex).remove(experimentTitleEditText);
experimentDescriptionsArray.get(localGroupIndex).remove(experimentDescriptionEditText); experimentDescriptionsArray.get(localGroupIndex).remove(experimentDescriptionEditText);
experimentInstructionsArray.get(localGroupIndex).remove(experimentInstructionsEditText); experimentInstructionsArray.get(localGroupIndex).remove(experimentInstructionsEditText);
experimentRelativeLayout.removeAllViews(); experimentRelativeLayout.removeAllViews();
deleteExperimentButtonParent.removeView(v); deleteExperimentButtonParent.removeView(v);
}
}); });
final Button addAnotherExperimentButton = new Button(NewBox.this); final Button addAnotherExperimentButton = new Button(NewBox.this);
textViewTempText = "Add Experiment"; textViewTempText = "Add Experiment";
addAnotherExperimentButton.setText(textViewTempText); addAnotherExperimentButton.setText(textViewTempText);
addAnotherExperimentButton.setOnClickListener(new View.OnClickListener() { addAnotherExperimentButton.setOnClickListener(v -> addExperimentFunction(localGroupIndex));
@Override
public void onClick(View v) {
addExperimentFunction(localGroupIndex);
}
});
RelativeLayout.LayoutParams deleteExperimentButtonAlignment = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams deleteExperimentButtonAlignment = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
deleteExperimentButtonAlignment.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); deleteExperimentButtonAlignment.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
...@@ -503,7 +473,6 @@ public class NewBox extends AppCompatActivity { ...@@ -503,7 +473,6 @@ public class NewBox extends AppCompatActivity {
return experimentRelativeLayout; return experimentRelativeLayout;
} }
// TODO: use this for the image upload on the other page, then its simply a case of trying to manage image processing
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
...@@ -528,7 +497,7 @@ public class NewBox extends AppCompatActivity { ...@@ -528,7 +497,7 @@ public class NewBox extends AppCompatActivity {
@Override @Override
public void onRequestPermissionsResult(int requestCode, public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions, @NonNull int[] grantResults) { @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == 1) {// If request is cancelled, the result arrays are empty. if (requestCode == 1) {
if (grantResults.length > 0 if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) { && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
d("dbg_Perm", "granted"); d("dbg_Perm", "granted");
...@@ -537,14 +506,11 @@ public class NewBox extends AppCompatActivity { ...@@ -537,14 +506,11 @@ public class NewBox extends AppCompatActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this); AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this);
builder.setTitle("Permission Required") builder.setTitle("Permission Required")
.setMessage("Permission to device storage is required for image upload.") .setMessage("Permission to device storage is required for image upload.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { .setPositiveButton("Ok", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package", getPackageName(), null)); intent.setData(Uri.fromParts("package", getPackageName(), null));
startActivityForResult(intent, 5); startActivityForResult(intent, 5);
}
}).setNegativeButton("Cancel", null).show(); }).setNegativeButton("Cancel", null).show();
} }
} }
......
package com.yearthreeproject.xbframework; package com.yearthreeproject.xbframework;
import android.annotation.SuppressLint;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
...@@ -17,13 +18,13 @@ import android.widget.Toast; ...@@ -17,13 +18,13 @@ import android.widget.Toast;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Calendar; import java.util.Calendar;
import java.util.Random; import java.util.Random;
...@@ -91,17 +92,14 @@ class ProjectMacros { ...@@ -91,17 +92,14 @@ class ProjectMacros {
sb.append(line).append("\n"); sb.append(line).append("\n");
} }
return sb.toString(); return sb.toString();
} catch (FileNotFoundException e) {
return "";
} catch (UnsupportedEncodingException e) {
return "";
} catch (IOException e) { } catch (IOException e) {
return ""; return "";
} }
} }
@SuppressLint("ShortAlarm")
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
static void createNotification(String contextTitle, String contextText, int resourceId, String channelId, Context currentClassDotThis, Calendar scheduledTime, Calendar repeatTime) { static void createNotification(String contextTitle, String contextText, Context currentClassDotThis, Calendar scheduledTime, Calendar repeatTime) {
int randSeed = 0; int randSeed = 0;
for(int i = 0; i < contextTitle.length(); i++){ for(int i = 0; i < contextTitle.length(); i++){
randSeed += contextTitle.charAt(i); randSeed += contextTitle.charAt(i);
...@@ -111,11 +109,11 @@ class ProjectMacros { ...@@ -111,11 +109,11 @@ class ProjectMacros {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE);
assert notificationManager != null; assert notificationManager != null;
if (notificationManager.getNotificationChannel(channelId) == null) { if (notificationManager.getNotificationChannel("ALL_CHANNEL") == null) {
CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1; CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1;
String description = "Channel started for " + contextTitle; String description = "Channel started for " + contextTitle;
int importance = NotificationManager.IMPORTANCE_DEFAULT; int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(channelId, name, importance); NotificationChannel channel = new NotificationChannel("ALL_CHANNEL", name, importance);
channel.setDescription(description); channel.setDescription(description);
notificationManager.createNotificationChannel(channel); notificationManager.createNotificationChannel(channel);
} }
...@@ -124,10 +122,10 @@ class ProjectMacros { ...@@ -124,10 +122,10 @@ class ProjectMacros {
Notification.Builder builder = new Notification.Builder(currentClassDotThis); Notification.Builder builder = new Notification.Builder(currentClassDotThis);
builder.setContentTitle(contextTitle); builder.setContentTitle(contextTitle);
builder.setContentText(contextText); builder.setContentText(contextText);
builder.setSmallIcon(resourceId); builder.setSmallIcon(R.raw.box_outline);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(channelId); builder.setChannelId("ALL_CHANNEL");
} }
Notification notification = new Notification.BigTextStyle(builder) Notification notification = new Notification.BigTextStyle(builder)
...@@ -146,12 +144,12 @@ class ProjectMacros { ...@@ -146,12 +144,12 @@ class ProjectMacros {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kkmmsshh"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kkmmsshh");
String repTimeString = simpleDateFormat.format(repeatTime.getTime()); String repTimeString = simpleDateFormat.format(repeatTime.getTime());
d("dbg_stringformat", repTimeString); d("dbg_time", repTimeString);
long millisRepeatTime = 0; long millisRepeatTime = 0;
if(Integer.parseInt(repTimeString.substring(0,2)) != 24) millisRepeatTime += Integer.parseInt(repTimeString.substring(0,2))*60*60*1000; if(Integer.parseInt(repTimeString.substring(0,2)) != 24) millisRepeatTime += Integer.parseInt(repTimeString.substring(0,2))*60*60*1000;
millisRepeatTime +=Integer.parseInt(repTimeString.substring(2,4))*60*1000+Integer.parseInt(repTimeString.substring(4,6))*1000; millisRepeatTime += Integer.parseInt(repTimeString.substring(4,6))*60*1000;
...@@ -170,7 +168,7 @@ class ProjectMacros { ...@@ -170,7 +168,7 @@ class ProjectMacros {
} }
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
static void cancelNotification(String contextTitle, String contextText, int resourceId, String channelId, Context currentClassDotThis){ static void cancelNotification(String contextTitle, String contextText, Context currentClassDotThis){
int randSeed = 0; int randSeed = 0;
for(int i = 0; i < contextTitle.length(); i++){ for(int i = 0; i < contextTitle.length(); i++){
randSeed += contextTitle.charAt(i); randSeed += contextTitle.charAt(i);
...@@ -180,11 +178,11 @@ class ProjectMacros { ...@@ -180,11 +178,11 @@ class ProjectMacros {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE);
assert notificationManager != null; assert notificationManager != null;
if (notificationManager.getNotificationChannel(channelId) == null) { if (notificationManager.getNotificationChannel("ALL_CHANNEL") == null) {
CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1; CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1;
String description = "Channel started for " + contextTitle; String description = "Channel started for " + contextTitle;
int importance = NotificationManager.IMPORTANCE_DEFAULT; int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(channelId, name, importance); NotificationChannel channel = new NotificationChannel("ALL_CHANNEL", name, importance);
channel.setDescription(description); channel.setDescription(description);
notificationManager.createNotificationChannel(channel); notificationManager.createNotificationChannel(channel);
} }
...@@ -193,10 +191,10 @@ class ProjectMacros { ...@@ -193,10 +191,10 @@ class ProjectMacros {
Notification.Builder builder = new Notification.Builder(currentClassDotThis); Notification.Builder builder = new Notification.Builder(currentClassDotThis);
builder.setContentTitle(contextTitle); builder.setContentTitle(contextTitle);
builder.setContentText(contextText); builder.setContentText(contextText);
builder.setSmallIcon(resourceId); builder.setSmallIcon(R.raw.box_outline);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(channelId); builder.setChannelId("ALL_CHANNEL");
} }
Notification notification = new Notification.BigTextStyle(builder) Notification notification = new Notification.BigTextStyle(builder)
...@@ -211,6 +209,7 @@ class ProjectMacros { ...@@ -211,6 +209,7 @@ class ProjectMacros {
PendingIntent pendingIntent = PendingIntent.getBroadcast(currentClassDotThis, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getBroadcast(currentClassDotThis, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) currentClassDotThis.getSystemService(Context.ALARM_SERVICE); AlarmManager alarmManager = (AlarmManager) currentClassDotThis.getSystemService(Context.ALARM_SERVICE);
assert alarmManager != null;
alarmManager.cancel(pendingIntent); alarmManager.cancel(pendingIntent);
} }
...@@ -272,4 +271,23 @@ class ProjectMacros { ...@@ -272,4 +271,23 @@ class ProjectMacros {
} }
return false; return false;
} }
static String readRaw(int resource, Context context) {
InputStream inputStream = context.getResources().openRawResource(resource);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
String outputString = "";
try {
ctr = inputStream.read();
while (ctr != -1) {
byteArrayOutputStream.write(ctr);
ctr = inputStream.read();
}
inputStream.close();
outputString = byteArrayOutputStream.toString();
} catch (Exception e) {
e.printStackTrace();
}
return outputString;
}
} }
...@@ -18,12 +18,24 @@ import androidx.annotation.RequiresApi; ...@@ -18,12 +18,24 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mongodb.stitch.android.core.Stitch;
import com.mongodb.stitch.android.core.StitchAppClient;
import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoClient;
import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoCollection;
import com.mongodb.stitch.core.services.mongodb.remote.RemoteUpdateOptions;
import org.bson.Document;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import static android.util.Log.d; import static android.util.Log.d;
...@@ -78,20 +90,17 @@ public class SurveyResponseActivity extends AppCompatActivity { ...@@ -78,20 +90,17 @@ public class SurveyResponseActivity extends AppCompatActivity {
} }
for (int i = 0; i < questions.length(); i++) { for (int i = 0; i < questions.length(); i++) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
surveyScrollView.addView(createNewQuestions(questions.get(i).toString(), i)); surveyScrollView.addView(createNewQuestions(questions.get(i).toString(), i));
} }
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
//FloatingActionButton fab = findViewById; FloatingActionButton fab = findViewById(R.id.surveyExperimentFAB);
/*fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(v -> completeSubmission());
@Override
public void onClick(View v) {
completeSubmission();
}
});*/
} }
private void completeSubmission() { private void completeSubmission() {
...@@ -102,14 +111,78 @@ public class SurveyResponseActivity extends AppCompatActivity { ...@@ -102,14 +111,78 @@ public class SurveyResponseActivity extends AppCompatActivity {
} }
if (correctSubmission) { if (correctSubmission) {
// TODO: handle the submission by inputting responses into some sort of JSON to be retained, for now do nothing JSONArray rawResponses = new JSONArray();
d("dbg_submit", responses.toString()); double averageResult = 0;
for(int i = 0; i < responses.size(); i++) {
rawResponses.put(responses.get(i));
averageResult += responses.get(i);
}
averageResult = averageResult / responses.size();
try {
JSONObject localDataJSON = new JSONObject(ProjectMacros.readFile(this, "localUserData.json"));
Date today = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY", Locale.getDefault());
JSONObject todaysResponse = new JSONObject().put("Results", rawResponses)
.put("Experiment", localDataJSON.getJSONObject("lockedExperiment").getString("Title"))
.put("Type", localDataJSON.getJSONObject("lockedExperiment").getString("Type"))
.put("Date", sdf.format(today))
.put("AverageResult", averageResult);
JSONObject lockedExperimentEdit = localDataJSON.getJSONObject("lockedExperiment");
JSONArray responseArray;
if(lockedExperimentEdit.optJSONArray("UserData") == null){
responseArray = new JSONArray();
} else {
responseArray = lockedExperimentEdit.getJSONArray("UserData");
}
responseArray.put(todaysResponse);
lockedExperimentEdit.put("UserData", responseArray);
localDataJSON.put("lockedExperiment", lockedExperimentEdit);
d("dbg_newData", localDataJSON.toString());
ProjectMacros.saveFile(SurveyResponseActivity.this, "localUserData.json", localDataJSON.toString());
final StitchAppClient client;
if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){
client = Stitch.getDefaultAppClient();
} else {
client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id));
}
final RemoteMongoClient mongoClient = client.getServiceClient(RemoteMongoClient.factory, "XBF");
final RemoteMongoCollection<Document> coll = mongoClient.getDatabase("IPServer").getCollection("UserData");
client.getAuth().addAuthListener(auth -> {
if(auth.isLoggedIn()){
coll.updateOne(
new Document("owner_id", auth.getUser().getId()),
Document.parse(localDataJSON.toString())
.append("owner_id", auth.getUser().getId()),
new RemoteUpdateOptions().upsert(true)).addOnCompleteListener(task1->{
d("dbg_uploaded", "success");
});
}
});
} catch (JSONException e) {
e.printStackTrace();
}
d("dbg_submit", rawResponses.toString());
finish(); finish();
} else { } else {
ProjectMacros.showToast(submitToast, SurveyResponseActivity.this, "Need to answer all the questions!"); ProjectMacros.showToast(submitToast, SurveyResponseActivity.this, "Need to answer all the questions!");
} }
} }
@RequiresApi(api = Build.VERSION_CODES.M)
private View createNewQuestions(String qText, final int index) { private View createNewQuestions(String qText, final int index) {
RelativeLayout relLayout = new RelativeLayout(this); RelativeLayout relLayout = new RelativeLayout(this);
...@@ -159,9 +232,7 @@ public class SurveyResponseActivity extends AppCompatActivity { ...@@ -159,9 +232,7 @@ public class SurveyResponseActivity extends AppCompatActivity {
relLayout.addView(questionText, questionTextAlignment); relLayout.addView(questionText, questionTextAlignment);
for (int i = 0; i < buttonArray.size(); i++) { for (int i = 0; i < buttonArray.size(); i++) {
buttonArray.get(i).setOnClickListener(new View.OnClickListener() { buttonArray.get(i).setOnClickListener(v -> {
@Override
public void onClick(View v) {
for (int x = 0; x < buttonArray.size(); x++) { for (int x = 0; x < buttonArray.size(); x++) {
if (x + 1 != v.getId()) { if (x + 1 != v.getId()) {
buttonArray.get(x).setChecked(false); buttonArray.get(x).setChecked(false);
...@@ -170,7 +241,6 @@ public class SurveyResponseActivity extends AppCompatActivity { ...@@ -170,7 +241,6 @@ public class SurveyResponseActivity extends AppCompatActivity {
responses.set(index, x + 1); responses.set(index, x + 1);
} }
} }
}
}); });
relLayout.addView(buttonArray.get(i), buttonArrayAlignment.get(i)); relLayout.addView(buttonArray.get(i), buttonArrayAlignment.get(i));
relLayout.addView(textViewArray.get(i), textViewArrayAlignment.get(i)); relLayout.addView(textViewArray.get(i), textViewArrayAlignment.get(i));
......
...@@ -102,7 +102,7 @@ public class TestingActivity extends AppCompatActivity { ...@@ -102,7 +102,7 @@ public class TestingActivity extends AppCompatActivity {
secondTestButton.setOnClickListener(new View.OnClickListener() { secondTestButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ProjectMacros.cancelNotification("Test Notification", "This is a test notification for the notification system!", R.raw.box_outline, "ALL_CHANNEL", TestingActivity.this); ProjectMacros.cancelNotification("Test Notification", "This is a test notification for the notification system!", TestingActivity.this);
} }
}); });
...@@ -133,7 +133,7 @@ public class TestingActivity extends AppCompatActivity { ...@@ -133,7 +133,7 @@ public class TestingActivity extends AppCompatActivity {
d("dbg_notificationChnls", String.valueOf(notificationManager.getNotificationChannels())); d("dbg_notificationChnls", String.valueOf(notificationManager.getNotificationChannels()));
} }
ProjectMacros.createNotification("Test Notification", "This is a test notification for the notification system!", R.raw.box_outline, "ALL_CHANNEL", TestingActivity.this, timeNowOffset, repeatTime); ProjectMacros.createNotification("Test Notification", "This is a test notification for the notification system!", TestingActivity.this, timeNowOffset, repeatTime);
} }
}); });
......
...@@ -21,7 +21,19 @@ ...@@ -21,7 +21,19 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="1" /> android:weightSum="1" >
</LinearLayout>
</ScrollView> </ScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/CreateNewBoxFab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_weight="0"
app:backgroundTint="@color/colorPrimary"
app:fabSize="normal"
app:srcCompat="@android:drawable/ic_menu_add" />
</LinearLayout> </LinearLayout>
...@@ -12,56 +12,38 @@ ...@@ -12,56 +12,38 @@
tools:context=".MainActivity" tools:context=".MainActivity"
tools:showIn="@layout/activity_main"> tools:showIn="@layout/activity_main">
<Button
android:id="@+id/HomeHomeButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground"
android:textColor="@color/colorPrimary"
android:layout_weight="1"
android:text="@string/main_home" />
<Button
android:id="@+id/HomeLoginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground"
android:textColor="@color/colorPrimary"
android:layout_weight="1"
android:text="@string/main_login" />
<Button <Button
android:id="@+id/HomeSurveyButton" android:id="@+id/HomeSurveyButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground" android:backgroundTint="@color/colorPrimaryAccent"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/HomeSurvey" /> android:text="@string/HomeSurvey" />
<Button <Button
android:id="@+id/HomeShopButton" android:id="@+id/HomeExperimentsButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground"
android:textColor="@color/colorPrimary"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/main_shop" /> android:backgroundTint="@color/colorPrimaryAccent"
android:text="@string/main_experiments"
android:textColor="@color/colorPrimary" />
<Button <Button
android:id="@+id/HomeExperimentsButton" android:id="@+id/HomeShopButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground" android:backgroundTint="@color/colorPrimaryAccent"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/main_experiments" /> android:text="@string/main_shop" />
<Button <Button
android:id="@+id/HomeProgressButton" android:id="@+id/HomeProgressButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground" android:backgroundTint="@color/colorPrimaryAccent"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/main_progress" /> android:text="@string/main_progress" />
...@@ -70,7 +52,7 @@ ...@@ -70,7 +52,7 @@
android:id="@+id/HomeAboutButton" android:id="@+id/HomeAboutButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@color/calendarBackground" android:backgroundTint="@color/colorPrimaryAccent"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/main_about" /> android:text="@string/main_about" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment