diff --git a/.idea/dictionaries/eamon.xml b/.idea/dictionaries/eamon.xml new file mode 100644 index 0000000000000000000000000000000000000000..f4f7eaf61182442aa7be9ea9616efe492ff03218 --- /dev/null +++ b/.idea/dictionaries/eamon.xml @@ -0,0 +1,7 @@ +<component name="ProjectDictionaryState"> + <dictionary name="eamon"> + <words> + <w>mongo</w> + </words> + </dictionary> +</component> \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..e3b610014b8dd9dbd7d725cfb845f11cd79711f0 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ +<?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 diff --git a/.idea/misc.xml b/.idea/misc.xml index 6630d507e4c25233f2c54720177f53625cb8d83b..687d49ee235948541fe677550c732be76d714798 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -39,7 +39,7 @@ </value> </option> </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" /> </component> <component name="ProjectType"> diff --git a/.idea/workspace-DESKTOP-6HHPPQT-2.xml b/.idea/workspace-DESKTOP-6HHPPQT-2.xml new file mode 100644 index 0000000000000000000000000000000000000000..0ea735d94fb2db22a46b2b6777712350bcb26b1c --- /dev/null +++ b/.idea/workspace-DESKTOP-6HHPPQT-2.xml @@ -0,0 +1,677 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="AndroidLayouts"> + <shared> + <config /> + </shared> + </component> + <component name="AndroidLogFilters"> + <option name="TOOL_WINDOW_LOG_LEVEL" value="verbose" /> + <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" /> + </component> + <component name="BookmarkManager"> + <bookmark url="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" line="41" /> + </component> + <component name="ChangeListManager"> + <list default="true" id="901156b8-4ed3-48c9-9feb-1fa598856dd4" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java" 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="DefaultGradleProjectSettings"> + <option name="isMigrated" value="true" /> + </component> + <component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_2_API_29" /> + <component name="ExternalProjectsManager"> + <system id="GRADLE"> + <state> + <projects_view> + <tree_state> + <expand> + <path> + <item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" /> + <item name="XBFramework" type="f1a62948:ProjectNode" /> + </path> + </expand> + <select /> + </tree_state> + </projects_view> + </state> + </system> + </component> + <component name="FileEditorManager"> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="255"> + <caret line="87" lean-forward="true" selection-start-line="87" selection-end-line="87" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="289"> + <caret line="25" column="60" selection-start-line="25" selection-start-column="60" selection-end-line="25" selection-end-column="60" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="391"> + <caret line="67" selection-start-line="67" selection-end-line="67" /> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="valueResourceFile" /> + <option value="resourceFile" /> + <option value="Class" /> + <option value="layoutResourceFile_vertical" /> + </list> + </option> + </component> + <component name="FindInProjectRecents"> + <findStrings> + <find>testing</find> + <find>loginButton</find> + <find>Delete</find> + <find>CropImage</find> + <find>TitleList</find> + <find>experimentTitle</find> + <find>EditText</find> + <find>ID</find> + <find>getid</find> + <find>groupIndex</find> + <find>inFiveLayout</find> + <find>ExperimentIndex</find> + <find>MEECS</find> + <find>locked</find> + <find>DateUntil</find> + </findStrings> + </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ArtefactShop.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_shop.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_progress.xml" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/NewExperiment.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_new_activity.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_new_experiment.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_new_experiment.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/values/strings.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/drawable/ic_logo.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/values/colors.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_about.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/values/idValues.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_about.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_boxes.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_experiments_list.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_login.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_progress.xml" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentsListActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_experiment.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_shop.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/raw/shop.json" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/CommonFunctions.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_experiment_survey_creator_activity.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_experiment_survey_creator_.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_experiment_survey_creator.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_experiment_survey_creator.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_new_box.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/raw/box.json" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/FileStoreReader.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/values/arrays.xml" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java" /> + <option value="$USER_HOME$/Documents/AndroidStudio/DeviceExplorer/emulator-5554/data/data/com.yearthreeproject.xbframework/files/localUserData.json" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_main.xml" /> + <option value="$PROJECT_DIR$/app/src/main/res/drawable/notification_icon.xml" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MyNotificationPublisher.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/TestingPage.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/activity_testing.xml" /> + <option value="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/res/layout/content_testing.xml" /> + <option value="$PROJECT_DIR$/build.gradle" /> + <option value="$PROJECT_DIR$/settings.gradle" /> + <option value="$PROJECT_DIR$/app/build.gradle" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java" /> + <option value="$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java" /> + </list> + </option> + </component> + <component name="ProjectFrameBounds" extendedState="6"> + <option name="x" value="2" /> + <option name="y" value="-8" /> + <option name="width" value="792" /> + <option name="height" value="1566" /> + </component> + <component name="ProjectLevelVcsManager" settingsEditedManually="true" /> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="Scope" /> + <pane id="AndroidView"> + <subPane> + <expand> + <path> + <item name="XBFramework" type="1abcf292:AndroidViewProjectNode" /> + <item name="Gradle Scripts" type="ae0cef3a:AndroidBuildScriptsGroupNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + <pane id="ProjectPane" /> + <pane id="PackagesPane" /> + </panes> + </component> + <component name="PropertiesComponent"> + <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="Project" /> + <property name="project.structure.proportion" value="0.17" /> + <property name="project.structure.side.proportion" value="0.0" /> + <property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" /> + </component> + <component name="RecentsManager"> + <key name="CreateClassDialog.RecentsKey"> + <recent name="com.yearthreeproject.xbframework" /> + </key> + <key name="MoveFile.RECENT_KEYS"> + <recent name="C:\Users\Eamonn\OneDrive\Documents\Y3Proj\app\src\main\res\raw" /> + </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="USE_LAST_SELECTED_DEVICE" value="false" /> + <option name="PREFERRED_AVD" value="" /> + <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 Changes: - Implemented a button to reset the boxJSONData - 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 Changes: - Implemented Date check for boxes - 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 Changes: - Implemented more of the survey creation page including: 0 A notification section 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 Changes: - Created the "template" for all the experiment details that can be manipulated - 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> + <option name="localTasksCounter" value="7" /> + <servers /> + </component> + <component name="TodoView"> + <todo-panel id="selected-file"> + <is-autoscroll-to-source value="true" /> + </todo-panel> + <todo-panel id="all"> + <are-packages-shown value="true" /> + <is-autoscroll-to-source value="true" /> + </todo-panel> + </component> + <component name="ToolWindowManager"> + <frame x="-6" y="-6" width="1513" height="973" extended-state="6" /> + <editor active="true" /> + <layout> + <window_info id="Captures" order="0" sideWeight="0.5071048" side_tool="true" weight="0.15672205" /> + <window_info id="Structure" order="1" side_tool="true" /> + <window_info id="Favorites" order="2" side_tool="true" /> + <window_info id="Build Variants" order="3" side_tool="true" /> + <window_info id="Image Layers" order="4" /> + <window_info id="Designer" order="5" /> + <window_info content_ui="combo" id="Project" order="6" sideWeight="0.35371178" visible="true" weight="0.10927835" /> + <window_info id="Resources Explorer" order="7" show_stripe_button="false" sideWeight="0.49858624" weight="0.3289275" /> + <window_info id="Capture Tool" order="8" /> + <window_info id="Device File Explorer" order="9" sideWeight="0.6462882" side_tool="true" visible="true" weight="0.10927835" /> + <window_info anchor="bottom" id="Messages" order="0" sideWeight="0.49960256" weight="0.32936078" /> + <window_info anchor="bottom" id="Run" order="1" sideWeight="0.49823323" weight="0.32384342" /> + <window_info anchor="bottom" id="TODO" order="2" sideWeight="0.49960256" weight="0.32574567" /> + <window_info anchor="bottom" id="Debug" order="3" /> + <window_info anchor="bottom" id="Terminal" order="4" sideWeight="0.49960256" weight="0.32810047" /> + <window_info anchor="bottom" id="Version Control" order="5" sideWeight="0.49920508" weight="0.32810047" /> + <window_info anchor="bottom" id="Build" order="6" sideWeight="0.4898036" weight="0.14709371" /> + <window_info anchor="bottom" id="Android Profiler" order="7" weight="0.32967034" /> + <window_info anchor="bottom" id="Find" order="8" sideWeight="0.49705535" weight="0.3289166" /> + <window_info active="true" anchor="bottom" id="Event Log" order="9" sideWeight="0.48430142" visible="true" weight="0.18505338" /> + <window_info anchor="right" id="Capture Analysis" order="0" /> + <window_info anchor="right" id="Gradle" order="1" weight="0.32968277" /> + <window_info anchor="right" id="Theme Preview" order="2" /> + <window_info anchor="right" id="Preview" order="3" weight="0.35601375" /> + <window_info anchor="right" id="Palette	" order="4" /> + <window_info anchor="right" id="Assistant" order="5" weight="0.32942432" /> + <window_info anchor="right" id="Logcat" order="6" sideWeight="0.49058086" visible="true" weight="0.23230241" /> + </layout> + </component> + <component name="VcsManagerConfiguration"> + <MESSAGE value="Change to v0.0.1" /> + <MESSAGE value="Change to v0.0.2" /> + <MESSAGE value="Daily Commit Changes: - Implemented a button to reset the boxJSONData - Implemented the addition to the boxJSON" /> + <MESSAGE value="Daily Commit Changes: - Implemented Date check for boxes - Introduced localUserData json for local meta data" /> + <MESSAGE value="Daily Commit Changes: - Implemented more of the survey creation page including: 0 A notification section 0 A completed survey layout (with one specific bug, but everything else works great)" /> + <MESSAGE value="Daily Commit Changes: - Created the "template" for all the experiment details that can be manipulated - Have defined a plan for the differences between the layout types and how to move forward" /> + <option name="LAST_COMMIT_MESSAGE" value="Daily Commit Changes: - Created the "template" for all the experiment details that can be manipulated - Have defined a plan for the differences between the layout types and how to move forward" /> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_main.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="323"> + <caret line="19" column="67" lean-forward="true" selection-start-line="19" selection-start-column="67" selection-end-line="19" selection-end-column="67" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_new_box.xml"> + <provider selected="true" editor-type-id="text-editor" /> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_boxes.xml"> + <provider editor-type-id="text-editor"> + <state relative-caret-position="493"> + <caret line="29" column="45" lean-forward="true" selection-start-line="29" selection-start-column="45" selection-end-line="29" selection-end-column="45" /> + </state> + </provider> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_about.xml"> + <provider editor-type-id="text-editor"> + <state relative-caret-position="629"> + <caret line="37" column="11" lean-forward="true" selection-start-line="37" selection-start-column="11" selection-end-line="37" selection-end-column="11" /> + </state> + </provider> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/mipmap-xhdpi/ic_launcher.png"> + <provider selected="true" editor-type-id="images" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/mipmap-hdpi/ic_launcher.png"> + <provider selected="true" editor-type-id="images" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_shop.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="646"> + <caret line="38" column="15" selection-start-line="38" selection-start-column="15" selection-end-line="38" selection-end-column="15" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/raw/shop.json" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/drawable/ic_launcher_background.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state> + <caret selection-end-column="2" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/drawable-v24/ic_launcher_foreground.xml"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/menu/menu_main.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="170"> + <caret line="10" lean-forward="true" selection-start-line="10" selection-end-line="10" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/CommonFunctions.java" /> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="408"> + <caret line="24" column="61" selection-start-line="24" selection-start-column="61" selection-end-line="24" selection-end-column="61" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_experiment.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="476"> + <caret line="28" column="54" lean-forward="true" selection-end-line="28" selection-end-column="54" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_experiment.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="17"> + <caret line="1" column="62" selection-end-line="51" selection-end-column="15" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_experiment_survey_creator.xml" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_experiment_survey_creator.xml" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_new_box.xml"> + <provider editor-type-id="text-editor"> + <state relative-caret-position="3162"> + <caret line="186" column="27" selection-start-line="186" selection-start-column="27" selection-end-line="186" selection-end-column="27" /> + </state> + </provider> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$USER_HOME$/Documents/AndroidStudio/DeviceExplorer/Pixel_2_API_29 [emulator-5554]/data/data/com.yearthreeproject.xbframework/files/boxData.json" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/values/arrays.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="187"> + <caret line="11" column="12" lean-forward="true" selection-start-line="11" selection-start-column="12" selection-end-line="11" selection-end-column="12" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/FileStoreReader.java" /> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="678"> + <caret line="149" column="49" lean-forward="true" selection-start-line="149" selection-start-column="49" selection-end-line="149" selection-end-column="49" /> + </state> + </provider> + </entry> + <entry file="file://$USER_HOME$/Documents/AndroidStudio/DeviceExplorer/emulator-5554/data/data/com.yearthreeproject.xbframework/files/boxData.json" /> + <entry file="file://$USER_HOME$/Documents/AndroidStudio/DeviceExplorer/emulator-5554/data/data/com.yearthreeproject.xbframework/files/localUserData.json" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_main.xml"> + <provider editor-type-id="text-editor"> + <state relative-caret-position="374"> + <caret line="22" column="25" selection-start-line="22" selection-start-column="25" selection-end-line="22" selection-end-column="25" /> + </state> + </provider> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="2023"> + <caret line="147" column="88" selection-start-line="147" selection-start-column="88" selection-end-line="147" selection-end-column="88" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/drawable/notification_icon.xml" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_shop.xml"> + <provider editor-type-id="text-editor" /> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_progress.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state> + <caret selection-end-line="27" selection-end-column="15" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/AndroidManifest.xml"> + <provider editor-type-id="android-manifest" /> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="442"> + <caret line="35" column="34" selection-start-line="35" selection-start-column="34" selection-end-line="35" selection-end-column="34" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/activity_testing.xml" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_progress.xml"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="561"> + <caret line="33" lean-forward="true" selection-end-line="40" selection-end-column="15" /> + </state> + </provider> + <provider editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MyNotificationPublisher.java" /> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_testing.xml" /> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="4182"> + <caret line="279" column="58" selection-start-line="279" selection-start-column="58" selection-end-line="279" selection-end-column="58" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/build.gradle"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="340"> + <caret line="20" column="8" selection-start-line="20" selection-start-column="8" selection-end-line="20" selection-end-column="8" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/build.gradle"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="476"> + <caret line="28" column="41" lean-forward="true" selection-start-line="28" selection-start-column="41" selection-end-line="28" selection-end-column="41" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/gradle/wrapper/gradle-wrapper.properties"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/proguard-rules.pro"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/gradle.properties"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/settings.gradle"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="17"> + <caret line="1" column="30" selection-start-line="1" selection-start-column="30" selection-end-line="1" selection-end-column="30" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/local.properties"> + <provider selected="true" editor-type-id="text-editor" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="680"> + <caret line="63" column="35" selection-start-line="63" selection-start-column="23" selection-end-line="63" selection-end-column="35" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="357"> + <caret line="21" lean-forward="true" selection-start-line="21" selection-end-line="21" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/raw/box.json"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="315"> + <caret line="38" column="23" lean-forward="true" selection-start-line="38" selection-start-column="23" selection-end-line="38" selection-end-column="23" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="623"> + <caret line="102" column="48" lean-forward="true" selection-start-line="102" selection-start-column="48" selection-end-line="102" selection-end-column="48" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/res/layout/content_login.xml"> + <provider editor-type-id="text-editor"> + <state relative-caret-position="170"> + <caret line="10" column="64" selection-start-line="10" selection-start-column="64" selection-end-line="10" selection-end-column="64" /> + </state> + </provider> + <provider selected="true" editor-type-id="android-designer2" /> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="255"> + <caret line="87" lean-forward="true" selection-start-line="87" selection-end-line="87" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="289"> + <caret line="25" column="60" selection-start-line="25" selection-start-column="60" selection-end-line="25" selection-end-column="60" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="391"> + <caret line="67" selection-start-line="67" selection-end-line="67" /> + </state> + </provider> + </entry> + </component> +</project> \ No newline at end of file diff --git a/.idea/workspace-DESKTOP-6HHPPQT-3.xml b/.idea/workspace-DESKTOP-6HHPPQT-3.xml new file mode 100644 index 0000000000000000000000000000000000000000..6effc8510c0f454d143d86b4679123de46ec6caa --- /dev/null +++ b/.idea/workspace-DESKTOP-6HHPPQT-3.xml @@ -0,0 +1,313 @@ +<?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: - 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 Changes: - Implemented a button to reset the boxJSONData - 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 Changes: - Implemented Date check for boxes - 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 Changes: - Implemented more of the survey creation page including: 0 A notification section 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 Changes: - Created the "template" for all the experiment details that can be manipulated - 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: - 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: - Completed the survey response functionality - 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: - 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: - 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: - 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: - 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 Changes: - Implemented a button to reset the boxJSONData - Implemented the addition to the boxJSON" /> + <MESSAGE value="Daily Commit Changes: - Implemented Date check for boxes - Introduced localUserData json for local meta data" /> + <MESSAGE value="Daily Commit Changes: - Implemented more of the survey creation page including: 0 A notification section 0 A completed survey layout (with one specific bug, but everything else works great)" /> + <MESSAGE value="Daily Commit Changes: - Created the "template" for all the experiment details that can be manipulated - Have defined a plan for the differences between the layout types and how to move forward" /> + <MESSAGE value="Changes since last commit: - Finished the newBox and ExperimentSurveyCreator pages - Full JSON production is completed so far for the boxes and experiments" /> + <MESSAGE value="Changes since last commit: - Made small changes to code to suppress typos or errors or warnings" /> + <MESSAGE value="Changes since last commit: - Completed the survey response functionality - Started with the notification functionality, have a worked version in testing activity (dev screen)" /> + <MESSAGE value="Changes since last commit: - Fixing local index issue" /> + <MESSAGE value="Changes since last commit: - Colour changes for most pages" /> + <option name="LAST_COMMIT_MESSAGE" value="Changes since last commit: - Colour changes for most pages" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/workspace-DESKTOP-FQUKLHE.xml b/.idea/workspace-DESKTOP-FQUKLHE.xml new file mode 100644 index 0000000000000000000000000000000000000000..67b0b63c9503f58ae0c63aa09337cf91c715b748 --- /dev/null +++ b/.idea/workspace-DESKTOP-FQUKLHE.xml @@ -0,0 +1,318 @@ +<?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: - Finished progress page - 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 Changes: - Implemented a button to reset the boxJSONData - 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 Changes: - Implemented Date check for boxes - 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 Changes: - Implemented more of the survey creation page including: 0 A notification section 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 Changes: - Created the "template" for all the experiment details that can be manipulated - 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: - 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: - Completed the survey response functionality - 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: - 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: - 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: - 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: - 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: - Finished progress page - 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 Changes: - Implemented a button to reset the boxJSONData - Implemented the addition to the boxJSON" /> + <MESSAGE value="Daily Commit Changes: - Implemented Date check for boxes - Introduced localUserData json for local meta data" /> + <MESSAGE value="Daily Commit Changes: - Implemented more of the survey creation page including: 0 A notification section 0 A completed survey layout (with one specific bug, but everything else works great)" /> + <MESSAGE value="Daily Commit Changes: - Created the "template" for all the experiment details that can be manipulated - Have defined a plan for the differences between the layout types and how to move forward" /> + <MESSAGE value="Changes since last commit: - Finished the newBox and ExperimentSurveyCreator pages - Full JSON production is completed so far for the boxes and experiments" /> + <MESSAGE value="Changes since last commit: - Made small changes to code to suppress typos or errors or warnings" /> + <MESSAGE value="Changes since last commit: - Completed the survey response functionality - Started with the notification functionality, have a worked version in testing activity (dev screen)" /> + <MESSAGE value="Changes since last commit: - Fixing local index issue" /> + <MESSAGE value="Changes since last commit: - Colour changes for most pages" /> + <MESSAGE value="Changes since last commit: - Finished progress page - Implemented Auth0 login and signup" /> + <option name="LAST_COMMIT_MESSAGE" value="Changes since last commit: - Finished progress page - Implemented Auth0 login and signup" /> + </component> +</project> \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9f47ba17aba93a22e024e6d3e3a524a748a557d4..a32ae6cf606887e6593a6bf2ed164fc19d0ee04c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,16 +2,19 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 - buildToolsVersion "29.0.2" + buildToolsVersion "29.0.3" defaultConfig { vectorDrawables.useSupportLibrary = true applicationId "com.yearthreeproject.xbframework" - minSdkVersion 16 + minSdkVersion 21 targetSdkVersion 29 versionCode 1 versionName "1.0" 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 { release { @@ -29,13 +32,12 @@ dependencies { //noinspection GradleCompatible implementation 'com.android.support:cardview-v7:28.0.0' 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.espresso:espresso-core:3.2.0' implementation 'com.google.android.material:material:1.1.0' api 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.jjoe64:graphview:4.2.2' implementation 'com.github.sundeepk:compact-calendar-view:3.0.0' - implementation 'com.auth0.android:auth0:1.22.1' - implementation 'com.auth0.android:lock:2.7.0' + implementation 'org.mongodb:stitch-android-sdk:4.1.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 99f831b27cad425cd9965acd2e0a2f80b295600e..53647ef03e9dd6ec39aa99750ba81b8a5a1e3bca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,6 +17,7 @@ tools:ignore="GoogleAppIndexingWarning"> <activity android:name=".MainActivity" + tools:overrideLibrary="com.mongodb.stitch.android.services.mongodb.remote" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> @@ -25,13 +26,6 @@ </intent-filter> </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 android:name=".AboutActivity" android:label="About" diff --git a/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java index 4616b0520a2856dfb27efdccc67a352d3f74b1b7..c0c07515eb12a6c64b68d60c03ab7fafdd70b519 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java @@ -1,12 +1,10 @@ package com.yearthreeproject.xbframework; import android.content.Intent; -import android.graphics.Color; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.util.TypedValue; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -18,14 +16,14 @@ import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.Objects; -import static android.util.Log.d; - public class BoxesActivity extends AppCompatActivity { @Override @@ -34,23 +32,9 @@ public class BoxesActivity extends AppCompatActivity { 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) @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - // Ordinary setup of UI for general app purposes super.onCreate(savedInstanceState); setContentView(R.layout.activity_boxes); Toolbar toolbar = findViewById(R.id.toolbar); @@ -64,8 +48,9 @@ public class BoxesActivity extends AppCompatActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(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(); } @@ -73,20 +58,16 @@ public class BoxesActivity extends AppCompatActivity { private void loadAndDisplayJSON() { LinearLayout inFiveLayout = findViewById(R.id.BoxesInFiveLayout); 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 { - - d("dbg_boxesParse", 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()]; - for (int i = 0; i < inFive.length; i++) { + for (int i = 0; i < inFive.length-1; i++) { inFiveLayoutArray[i] = new LinearLayout(this); TextView inFiveTitle = new TextView(this); @@ -94,7 +75,9 @@ public class BoxesActivity extends AppCompatActivity { inFiveTitle.setText(inFive[i]); inFiveTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36); inFiveTitle.setPadding(0, 8, 0, 0); - inFiveTitle.setTextColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + inFiveTitle.setTextColor(getColor(R.color.colorPrimary)); + } inFiveLayoutArray[i].setOrientation(LinearLayout.VERTICAL); inFiveLayoutArray[i].addView(inFiveTitle); @@ -102,7 +85,9 @@ public class BoxesActivity extends AppCompatActivity { View hr = new View(this); ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); 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); @@ -121,10 +106,14 @@ public class BoxesActivity extends AppCompatActivity { TextView titleOfBox = new TextView(this); titleOfBox.setText(box.getString("Name")); titleOfBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28); - titleOfBox.setTextColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + titleOfBox.setTextColor(getColor(R.color.colorPrimary)); + } TextView descriptionOfBox = new TextView(this); - descriptionOfBox.setTextColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + descriptionOfBox.setTextColor(getColor(R.color.colorPrimary)); + } descriptionOfBox.setText(box.getString("Blurb")); @@ -132,35 +121,24 @@ public class BoxesActivity extends AppCompatActivity { boxLayout.addView(descriptionOfBox); ImageView boxLogo; - if (!box.getString("Image").equals("null")) { + if (box.getString("Image").equals("null")) { boxLogo = new ImageView(this); boxLogo.setImageResource(R.mipmap.ic_launcher); 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].setId(j); - inFiveAvailableBoxes[j].setOnClickListener(new View.OnClickListener() { - @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); - openPage.putExtra("JSON", box.toString()); - startActivity(openPage); - finish(); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } + inFiveAvailableBoxes[j].setOnClickListener(v -> { + Intent openPage = new Intent(BoxesActivity.this, ExperimentActivity.class); + openPage.putExtra("JSON", box.toString()); + startActivity(openPage); + finish(); }); inFiveLayoutArray[i].addView(inFiveAvailableBoxes[j]); } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java index 20d54bc2f2317f19f1f9573b7e420d6089b06203..3f22dac7b00fc7f50c30fef49cb3e6b73c896cdc 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java @@ -1,5 +1,8 @@ package com.yearthreeproject.xbframework; +import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.graphics.Color; import android.icu.text.SimpleDateFormat; import android.os.Build; @@ -17,14 +20,19 @@ import androidx.appcompat.app.AppCompatActivity; 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.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Calendar; -import java.util.Objects; import static android.util.Log.d; import static java.util.Objects.requireNonNull; @@ -49,7 +57,7 @@ public class ExperimentActivity extends AppCompatActivity { toolbar.setNestedScrollingEnabled(false); } setSupportActionBar(toolbar); - Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); + requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); getSupportActionBar().setLogo(R.mipmap.ic_launcher); getSupportActionBar().setDisplayUseLogoEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -71,7 +79,9 @@ public class ExperimentActivity extends AppCompatActivity { */ TextView boxDescription = new TextView(this); - boxDescription.setTextColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + boxDescription.setTextColor(getColor(R.color.colorPrimary)); + } boxDescription.setText(Html.fromHtml(boxJSON.getString("Description") + "<font color=red> " + boxJSON.getString("WarningText") + "</font color>")); @@ -89,13 +99,17 @@ public class ExperimentActivity extends AppCompatActivity { View hr = new View(this); ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); hr.setLayoutParams(hrLayoutParams); - hr.setBackgroundColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + hr.setBackgroundColor(getColor(R.color.colorPrimary)); + } hr.setPadding(0, 0, 0, 16); TextView experimentGroupName = new TextView(this); experimentGroupName.setText(experimentsJSONArray.getJSONObject(i).getString("Group")); experimentGroupName.setPadding(0, 8, 0, 8); - experimentGroupName.setTextColor(getColor(R.color.colorPrimary)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + experimentGroupName.setTextColor(getColor(R.color.colorPrimary)); + } experimentInfoLayout.addView(hr); @@ -105,19 +119,22 @@ public class ExperimentActivity extends AppCompatActivity { for (int j = 0; j < experimentChoices.length(); j++) { 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); experimentRadioButton.setId(radioButtonUniqueId); experimentRadioButton.setText(experimentData.getString("Title")); - experimentRadioButton.setTextColor(getColor(R.color.colorPrimary)); - experimentRadioButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - for (int x = 0; x < experimentsRadioButtonArray.size(); x++) { - if (x != v.getId()) - experimentsRadioButtonArray.get(x).setChecked(false); - else experimentsRadioButtonArray.get(x).setChecked(true); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + experimentRadioButton.setTextColor(getColor(R.color.colorPrimary)); + } + experimentRadioButton.setOnClickListener(v -> { + for (int x = 0; x < experimentsRadioButtonArray.size(); x++) { + if (x != v.getId()) + experimentsRadioButtonArray.get(x).setChecked(false); + else experimentsRadioButtonArray.get(x).setChecked(true); } }); @@ -132,44 +149,66 @@ public class ExperimentActivity extends AppCompatActivity { } FloatingActionButton fab = findViewById(R.id.experimentFAB); - fab.setOnClickListener(new View.OnClickListener() { - @RequiresApi(api = Build.VERSION_CODES.N) - public void onClick(View v) { - for (int x = 0; x < experimentsRadioButtonArray.size(); x++) - if (experimentsRadioButtonArray.get(x).isChecked()) { - int pseudoCount = 0; - int experimentGroup = 0; - d("dbg_submit", experimentsRadioButtonArray.get(x).getText().toString()); - try { - JSONObject boxJSON = new JSONObject(requireNonNull(getIntent().getStringExtra("JSON"))); - for (int i = 0; i < boxJSON.getJSONArray("Experiments").length(); i++) { - if (boxJSON.getJSONArray("Experiments").getJSONObject(i).getJSONArray("Options").length() + pseudoCount <= x) { - pseudoCount += boxJSON.getJSONArray("Experiments").getJSONObject(i).getJSONArray("Options").length(); - experimentGroup++; - } else { - JSONObject editJSON = new JSONObject(ProjectMacros.readFile(ExperimentActivity.this, "localUserData.json")); - editJSON.put("lockedExperiment", boxJSON.getJSONArray("Experiments").getJSONObject(experimentGroup).getJSONArray("Options").getJSONObject(x - pseudoCount)); - - Calendar calendar = Calendar.getInstance(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); + fab.setOnClickListener(v -> { + for (int x = 0; x < experimentsRadioButtonArray.size(); x++) + if (experimentsRadioButtonArray.get(x).isChecked()) { + int pseudoCount = 0; + int experimentGroup = 0; + d("dbg_submit", experimentsRadioButtonArray.get(x).getText().toString()); + try { + JSONObject boxJSON = new JSONObject(requireNonNull(getIntent().getStringExtra("JSON"))); + for (int i = 0; i < boxJSON.getJSONArray("Experiments").length(); i++) { + if (boxJSON.getJSONArray("Experiments").getJSONObject(i).getJSONArray("Options").length() + pseudoCount <= x) { + pseudoCount += boxJSON.getJSONArray("Experiments").getJSONObject(i).getJSONArray("Options").length(); + experimentGroup++; + } else { + JSONObject editJSON = new JSONObject(ProjectMacros.readFile(ExperimentActivity.this, "localUserData.json")); + editJSON.put("lockedExperiment", boxJSON.getJSONArray("Experiments").getJSONObject(experimentGroup).getJSONArray("Options").getJSONObject(x - pseudoCount).put("Type", boxJSON.getString("Group"))); + + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); calendar.add(Calendar.DATE, 5); String dateUntil = simpleDateFormat.format(calendar.getTime()); - 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; - d("dbg_storedJSON", editJSON.toString()); - finish(); + 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()); + finish(); + }); + } + }); } - } catch (Exception e) { - e.printStackTrace(); } - + } catch (Exception e) { + e.printStackTrace(); } - } + + } }); } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java index 4a5ea799e438179dc6b1f0291bdb17f853fd7e0d..b806d9a836454483ae46767bfe80d293f41d04bd 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java @@ -13,7 +13,6 @@ import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RelativeLayout; @@ -28,7 +27,13 @@ import androidx.appcompat.app.AppCompatActivity; 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.JSONException; import org.json.JSONObject; @@ -109,12 +114,7 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { FloatingActionButton fab = findViewById(R.id.experimentSurveyCreatorFAB); fab.setImageResource(R.drawable.ic_action_right); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - submitCheck(); - } - }); + fab.setOnClickListener(v -> submitCheck()); initialGUILoad(boxInfo); @@ -167,12 +167,7 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { artefactLayout.addView(surveyToggleSlider, sliderAlignment); artefactLayout.addView(surveyTitle, titleAlignment); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - artefactImplementation = isChecked; - } - }); + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> artefactImplementation = isChecked); return artefactLayout; } @@ -199,12 +194,7 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { videoLayout.addView(surveyToggleSlider, sliderAlignment); videoLayout.addView(surveyTitle, titleAlignment); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - videoProcessing = isChecked; - } - }); + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> videoProcessing = isChecked); return videoLayout; } @@ -231,12 +221,7 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { audioLayout.addView(surveyToggleSlider, sliderAlignment); audioLayout.addView(surveyTitle, titleAlignment); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - audioProcessing = isChecked; - } - }); + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> audioProcessing = isChecked); return audioLayout; } @@ -263,12 +248,7 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { imageLayout.addView(surveyToggleSlider, sliderAlignment); imageLayout.addView(surveyTitle, titleAlignment); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - imageProcessing = isChecked; - } - }); + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> imageProcessing = isChecked); return imageLayout; } @@ -308,16 +288,13 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { createNewNotification(buttonLayout, buttonLayout); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked) { - notificationLayout.addView(buttonLayout); - customNotifications = true; - } else { - notificationLayout.removeView(buttonLayout); - customNotifications = false; - } + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + notificationLayout.addView(buttonLayout); + customNotifications = true; + } else { + notificationLayout.removeView(buttonLayout); + customNotifications = false; } }); @@ -374,13 +351,10 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { int hour = currentTime.get(Calendar.HOUR_OF_DAY); int minute = currentTime.get(Calendar.MINUTE); TimePickerDialog mTimePicker; - mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { - String textViewTempText = String.format("%2s", selectedHour).replace(' ', '0') + ":" + String.format("%2s", selectedMinute).replace(' ', '0'); - notificationTimeEditText.setText(textViewTempText); - } - }, hour, minute, true);//Yes 24 hour time + mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, (timePicker, selectedHour, selectedMinute) -> { + String textViewTempText1 = String.format("%2s", selectedHour).replace(' ', '0') + ":" + String.format("%2s", selectedMinute).replace(' ', '0'); + notificationTimeEditText.setText(textViewTempText1); + }, hour, minute, true); mTimePicker.setTitle("Select Time"); mTimePicker.show(); } @@ -396,23 +370,17 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { notificationRepeatEditText.setTextSize(9); notificationRepeatEditText.setFocusable(false); notificationRepeatEditText.setClickable(true); - notificationRepeatEditText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Calendar currentTime = Calendar.getInstance(); - int hour = currentTime.get(Calendar.HOUR_OF_DAY); - int minute = currentTime.get(Calendar.MINUTE); - TimePickerDialog mTimePicker; - mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { - String textViewTempText = String.format("%2s", selectedHour).replace(' ', '0') + ":" + String.format("%2s", selectedMinute).replace(' ', '0') + " hours"; - notificationRepeatEditText.setText(textViewTempText); - } - }, hour, minute, true);//Yes 24 hour time - mTimePicker.setTitle("Select Time"); - mTimePicker.show(); - } + notificationRepeatEditText.setOnClickListener(v1 -> { + Calendar currentTime = Calendar.getInstance(); + int hour = currentTime.get(Calendar.HOUR_OF_DAY); + int minute = currentTime.get(Calendar.MINUTE); + TimePickerDialog mTimePicker; + mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, (timePicker, selectedHour, selectedMinute) -> { + String textViewTempText12 = String.format("%2s", selectedHour).replace(' ', '0') + ":" + String.format("%2s", selectedMinute).replace(' ', '0') + " hours"; + notificationRepeatEditText.setText(textViewTempText12); + }, hour, minute, true);//Yes 24 hour time + mTimePicker.setTitle("Select Time"); + mTimePicker.show(); }); @@ -488,45 +456,36 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { notificationTimeEditTexts.add(notificationTimeEditText); notificationRepeatEditTexts.add(notificationRepeatEditText); - deleteNotificationButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v2) { - ViewGroup tempViewGroup = (ViewGroup) v2.getParent(); - tempViewGroup.removeAllViews(); - notificationLabels.remove(notificationLabel); - notificationMessageEditTexts.remove(notificationMessageEditText); - notificationTimeEditTexts.remove(notificationTimeEditText); - notificationRepeatEditTexts.remove(notificationRepeatEditText); - String textViewTempText; - - addNotificationButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v3) { - String textViewTempText; - for (int i = 1; i < notificationLabels.size(); i++) { - textViewTempText = "Notification " + (i) + ":"; - notificationLabels.get(i).setText(textViewTempText); - } - createNewNotification(v3, buttonLayout); - } - }); - + deleteNotificationButton.setOnClickListener(v2 -> { + ViewGroup tempViewGroup = (ViewGroup) v2.getParent(); + tempViewGroup.removeAllViews(); + notificationLabels.remove(notificationLabel); + notificationMessageEditTexts.remove(notificationMessageEditText); + notificationTimeEditTexts.remove(notificationTimeEditText); + notificationRepeatEditTexts.remove(notificationRepeatEditText); + String textViewTempText13; + + addNotificationButton.setOnClickListener(v3 -> { + String textViewTempText131; for (int i = 1; i < notificationLabels.size(); i++) { - textViewTempText = "Notification " + (i) + ":"; - notificationLabels.get(i).setText(textViewTempText); + textViewTempText131 = "Notification " + (i) + ":"; + notificationLabels.get(i).setText(textViewTempText131); } + createNewNotification(v3, buttonLayout); + }); + + for (int i = 1; i < notificationLabels.size(); i++) { + textViewTempText13 = "Notification " + (i) + ":"; + notificationLabels.get(i).setText(textViewTempText13); } }); - addNotificationButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v2) { - for (int i = 1; i < notificationLabels.size(); i++) { - String textViewTempText = "Notification " + (i) + ":"; - notificationLabels.get(i).setText(textViewTempText); - } - createNewNotification(v2, buttonLayout); + addNotificationButton.setOnClickListener(v2 -> { + for (int i = 1; i < notificationLabels.size(); i++) { + String textViewTempText14 = "Notification " + (i) + ":"; + notificationLabels.get(i).setText(textViewTempText14); } + createNewNotification(v2, buttonLayout); }); if (v.isClickable()) { @@ -579,40 +538,29 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { questionLabels.add(questionNumberLabel); questionEditTexts.add(questionEditText); - deleteQuestionButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v2) { - ViewGroup tempViewGroup = (ViewGroup) v2.getParent(); - tempViewGroup.removeAllViews(); - - questionEditTexts.remove(questionEditText); - questionLabels.remove(questionNumberLabel); - - addQuestionButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v3) { - for (int i = 1; i < questionLabels.size(); i++) { - String textViewTempText = "Question " + (i) + ":"; - questionLabels.get(i).setText(textViewTempText); - } - createNewQuestion(v3, buttonLayout); - } - }); + deleteQuestionButton.setOnClickListener(v2 -> { + ViewGroup tempViewGroup = (ViewGroup) v2.getParent(); + tempViewGroup.removeAllViews(); + + questionEditTexts.remove(questionEditText); + questionLabels.remove(questionNumberLabel); + addQuestionButton.setOnClickListener(v3 -> { for (int i = 1; i < questionLabels.size(); i++) { - String textViewTempText = "Question " + (i) + ":"; - questionLabels.get(i).setText(textViewTempText); + String textViewTempText1 = "Question " + (i) + ":"; + questionLabels.get(i).setText(textViewTempText1); } - } - }); + createNewQuestion(v3, buttonLayout); + }); - addQuestionButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v2) { - createNewQuestion(v2, buttonLayout); + for (int i = 1; i < questionLabels.size(); i++) { + String textViewTempText1 = "Question " + (i) + ":"; + questionLabels.get(i).setText(textViewTempText1); } }); + addQuestionButton.setOnClickListener(v2 -> createNewQuestion(v2, buttonLayout)); + if (v.isClickable()) { buttonLayout.removeView(v); buttonLayout.addView(addQuestionButton); @@ -697,33 +645,30 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { questionnaireAvailableToTime.setId(uniqueID++); questionnaireAvailableToTime.setFocusable(false); questionnaireAvailableToTime.setClickable(true); - questionnaireAvailableToTime.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Calendar currentTime = Calendar.getInstance(); - int hour = currentTime.get(Calendar.HOUR_OF_DAY); - int minute = currentTime.get(Calendar.MINUTE); - TimePickerDialog mTimePicker; - mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { - String textTempComparison = questionnaireAvailableFromTime.getText().toString(); - - if (selectedHour == Integer.parseInt(textTempComparison.substring(0, 2)) && selectedMinute >= Integer.parseInt(textTempComparison.substring(3, 5))) { - String textViewTempText = selectedHour + ":" + selectedMinute; - questionnaireAvailableToTime.setText(textViewTempText); - } else if (selectedHour > Integer.parseInt(textTempComparison.substring(0, 2))) { - String textViewTempText = selectedHour + ":" + selectedMinute; - questionnaireAvailableToTime.setText(textViewTempText); - } else { - questionnaireAvailableToTime.setText(textTempComparison); - showToast(submitToast, getApplicationContext(), "Time has been set to the same as 'to time' as the selected value was larger than possible!"); - } + questionnaireAvailableToTime.setOnClickListener(v -> { + Calendar currentTime = Calendar.getInstance(); + int hour = currentTime.get(Calendar.HOUR_OF_DAY); + int minute = currentTime.get(Calendar.MINUTE); + TimePickerDialog mTimePicker; + mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { + String textTempComparison = questionnaireAvailableFromTime.getText().toString(); + + if (selectedHour == Integer.parseInt(textTempComparison.substring(0, 2)) && selectedMinute >= Integer.parseInt(textTempComparison.substring(3, 5))) { + String textViewTempText1 = selectedHour + ":" + selectedMinute; + questionnaireAvailableToTime.setText(textViewTempText1); + } else if (selectedHour > Integer.parseInt(textTempComparison.substring(0, 2))) { + String textViewTempText1 = selectedHour + ":" + selectedMinute; + questionnaireAvailableToTime.setText(textViewTempText1); + } else { + questionnaireAvailableToTime.setText(textTempComparison); + showToast(submitToast, getApplicationContext(), "Time has been set to the same as 'to time' as the selected value was larger than possible!"); } - }, hour, minute, true);//Yes 24 hour time - mTimePicker.setTitle("Select Time"); - mTimePicker.show(); - } + } + }, hour, minute, true); + mTimePicker.setTitle("Select Time"); + mTimePicker.show(); }); questionnaireAvailableFromTime.setGravity(Gravity.TOP); @@ -732,33 +677,30 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { questionnaireAvailableFromTime.setId(uniqueID++); questionnaireAvailableFromTime.setFocusable(false); questionnaireAvailableFromTime.setClickable(true); - questionnaireAvailableFromTime.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Calendar currentTime = Calendar.getInstance(); - int hour = currentTime.get(Calendar.HOUR_OF_DAY); - int minute = currentTime.get(Calendar.MINUTE); - TimePickerDialog mTimePicker; - mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { - String textTempComparison = questionnaireAvailableToTime.getText().toString(); - - if (selectedHour == Integer.parseInt(textTempComparison.substring(0, 2)) && selectedMinute <= Integer.parseInt(textTempComparison.substring(3, 5))) { - String textViewTempText = selectedHour + ":" + selectedMinute; - questionnaireAvailableFromTime.setText(textViewTempText); - } else if (selectedHour < Integer.parseInt(textTempComparison.substring(0, 2))) { - String textViewTempText = selectedHour + ":" + selectedMinute; - questionnaireAvailableFromTime.setText(textViewTempText); - } else { - questionnaireAvailableFromTime.setText(textTempComparison); - showToast(submitToast, getApplicationContext(), "Time has been set to the same as 'to time' as the selected value was larger than possible!"); - } + questionnaireAvailableFromTime.setOnClickListener(v -> { + Calendar currentTime = Calendar.getInstance(); + int hour = currentTime.get(Calendar.HOUR_OF_DAY); + int minute = currentTime.get(Calendar.MINUTE); + TimePickerDialog mTimePicker; + mTimePicker = new TimePickerDialog(ExperimentSurveyCreatorActivity.this, new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { + String textTempComparison = questionnaireAvailableToTime.getText().toString(); + + if (selectedHour == Integer.parseInt(textTempComparison.substring(0, 2)) && selectedMinute <= Integer.parseInt(textTempComparison.substring(3, 5))) { + String textViewTempText12 = selectedHour + ":" + selectedMinute; + questionnaireAvailableFromTime.setText(textViewTempText12); + } else if (selectedHour < Integer.parseInt(textTempComparison.substring(0, 2))) { + String textViewTempText12 = selectedHour + ":" + selectedMinute; + questionnaireAvailableFromTime.setText(textViewTempText12); + } else { + questionnaireAvailableFromTime.setText(textTempComparison); + showToast(submitToast, getApplicationContext(), "Time has been set to the same as 'to time' as the selected value was larger than possible!"); } - }, hour, minute, true);//Yes 24 hour time - mTimePicker.setTitle("Select Time"); - mTimePicker.show(); - } + } + }, hour, minute, true); + mTimePicker.setTitle("Select Time"); + mTimePicker.show(); }); RelativeLayout.LayoutParams fromTimeAlignment = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); @@ -782,36 +724,30 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { final RelativeLayout.LayoutParams specificTimeInputLayoutAlignment = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); specificTimeInputLayoutAlignment.addRule(RelativeLayout.BELOW, specificTimeLabel.getId()); - toggleSpecificTime.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked) { - surveyLayout.addView(specificTimeInputLayout, specificTimeInputLayoutAlignment); - specificTime = true; - } else { - surveyLayout.removeView(specificTimeInputLayout); - specificTime = false; - } + toggleSpecificTime.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + surveyLayout.addView(specificTimeInputLayout, specificTimeInputLayoutAlignment); + specificTime = true; + } else { + surveyLayout.removeView(specificTimeInputLayout); + specificTime = false; } }); - surveyToggleSlider.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked) { - surveyLayout.addView(buttonLayout, questionLayoutAlignment); - surveyLayout.addView(toggleSpecificTime, toggleSpecificTimeAlignment); - surveyLayout.addView(specificTimeLabel, specificTimeLabelAlignment); - if (specificTime) - surveyLayout.addView(specificTimeInputLayout, specificTimeInputLayoutAlignment); - surveyQuestions = true; - } else { - surveyLayout.removeView(buttonLayout); - surveyLayout.removeView(toggleSpecificTime); - surveyLayout.removeView(specificTimeLabel); - surveyLayout.removeView(specificTimeInputLayout); - surveyQuestions = false; - } + surveyToggleSlider.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + surveyLayout.addView(buttonLayout, questionLayoutAlignment); + surveyLayout.addView(toggleSpecificTime, toggleSpecificTimeAlignment); + surveyLayout.addView(specificTimeLabel, specificTimeLabelAlignment); + if (specificTime) + surveyLayout.addView(specificTimeInputLayout, specificTimeInputLayoutAlignment); + surveyQuestions = true; + } else { + surveyLayout.removeView(buttonLayout); + surveyLayout.removeView(toggleSpecificTime); + surveyLayout.removeView(specificTimeLabel); + surveyLayout.removeView(specificTimeInputLayout); + surveyQuestions = false; } }); @@ -1019,14 +955,34 @@ public class ExperimentSurveyCreatorActivity extends AppCompatActivity { d("dbg_UpdatedJSON", boxes.toString()); - ProjectMacros.saveFile(ExperimentSurveyCreatorActivity.this, "boxData.json", boxes.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("Experiments"); + + client.getAuth().addAuthListener(auth ->{ + if(auth.isLoggedIn()){ + coll.updateOne( + new Document("SubmittedBy", auth.getUser().getId()), + Document.parse(boxInfo.toString()) + .append("SubmittedBy", auth.getUser().getId()), + new RemoteUpdateOptions().upsert(true)) + .addOnCompleteListener(task1->{ + d("dbg_was_succesful", String.valueOf(task1.isSuccessful())); + d("dbg_storedJSON", boxInfo.toString()); + Intent intent = new Intent(getApplicationContext(), BoxesActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + }); + } + }); } catch (Exception e) { e.printStackTrace(); } - - Intent intent = new Intent(getApplicationContext(), BoxesActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java index a456d8e9ba5148a55593a4ef5011fbfea0ff88b9..25107609195ebf68a7af2147526e5962e1ea63a6 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java @@ -1,33 +1,42 @@ package com.yearthreeproject.xbframework; +import android.content.Context; +import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; -import android.view.View; +import android.util.Log; import android.widget.Button; import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.Toast; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; -import com.auth0.android.Auth0; -import com.auth0.android.authentication.AuthenticationAPIClient; -import com.auth0.android.authentication.AuthenticationException; -import com.auth0.android.callback.BaseCallback; -import com.auth0.android.lock.AuthenticationCallback; -import com.auth0.android.lock.Lock; -import com.auth0.android.lock.utils.LockException; -import com.auth0.android.result.Credentials; - +import com.mongodb.DBObject; +import com.mongodb.stitch.android.core.Stitch; +import com.mongodb.stitch.android.core.StitchAppClient; +import com.mongodb.stitch.android.core.auth.providers.userpassword.UserPasswordAuthProviderClient; +import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoClient; +import com.mongodb.stitch.android.services.mongodb.remote.RemoteMongoCollection; +import com.mongodb.stitch.core.auth.providers.userpassword.UserPasswordCredential; +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 static android.util.Log.d; public class LoginActivity extends AppCompatActivity { - - private Auth0 auth0; - private Lock lock; + private Toast messageToast; @Override public boolean onSupportNavigateUp() { @@ -35,63 +44,127 @@ public class LoginActivity extends AppCompatActivity { 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) @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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); setSupportActionBar(toolbar); Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); getSupportActionBar().setLogo(R.mipmap.ic_launcher); getSupportActionBar().setDisplayUseLogoEnabled(true); - auth0 = new Auth0(getString(R.string.com_auth0_client_id), getString(R.string.com_auth0_domain)); - auth0.setOIDCConformant(true); - - lock = Lock.newBuilder(auth0, cb).build(this); + messageToast = new Toast(this); final EditText email = findViewById(R.id.EmailEditText); 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(); + + StringBuffer hexString = new StringBuffer(); + for (int i=0; i<messageDigested.length; i++) hexString.append(Integer.toHexString(0xFF & messageDigested[i])); + hashedPassword = hexString.toString(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } Button submitLoginButton = findViewById(R.id.LoginSubmitButton); - submitLoginButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - authentication - .login(email.getText().toString(), password.getText().toString(), "Username-Password-Authentication") - .start(new BaseCallback<Credentials, AuthenticationException>() { - @Override - public void onSuccess(Credentials payload) { - d("dbg_success", payload.getIdToken()); + String finalHashedPassword = hashedPassword; + 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"); + 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(); } - - @Override - public void onFailure(AuthenticationException error) { - d("dbg_failure", error.getMessage()); + 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{ + Log.e("STITCH", "Error: " + task.getException().toString()); + task.getException().printStackTrace(); + finish(); } }); - //startActivity(lock.newIntent(LoginActivity.this)); + }); + + + Button submitRegisterButton = new Button(this); + submitRegisterButton.setText("Register"); + 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!"); + }); }); } - - private AuthenticationCallback cb = new AuthenticationCallback() { - @Override - public void onError(LockException error) { - d("dbg_err", "err"); - } - - @Override - public void onAuthentication(Credentials credentials) { - d("dbg_success", "success"); - } - - @Override - public void onCanceled() { - d("dbg_cancelled", "cancelled"); - } - }; } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java index 496b20de4ef45b0abcb2750a3295675e43f299df..16cd17c5bc0ca7ced896e4c43cafabc254a7b412 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java @@ -1,9 +1,7 @@ package com.yearthreeproject.xbframework; import android.Manifest; -import android.annotation.SuppressLint; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -14,7 +12,6 @@ import android.os.Bundle; import android.provider.Settings; import android.view.Menu; import android.view.MenuItem; -import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; @@ -26,13 +23,21 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +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 org.bson.Document; +import org.bson.internal.Base64; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; +import java.security.SecureRandom; +import java.util.ArrayList; import java.util.Calendar; +import java.util.List; import java.util.Objects; import java.util.Random; @@ -41,189 +46,172 @@ import static android.util.Log.d; public class MainActivity extends AppCompatActivity { private boolean shouldRecreate; - Intent intentTest = new Intent(); + Intent recreateOnExitIntent = new Intent(); Toast submitToast; @Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem createBox = menu.add("Reset JSON!"); MenuItem cancelNotif = menu.add("Cancel Notifications!"); + MenuItem logOut = menu.add("Log out!"); - createBox.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @RequiresApi(api = Build.VERSION_CODES.KITKAT) - @Override - public boolean onMenuItemClick(MenuItem item) { - resetBoxJSON(); - return false; - } + createBox.setOnMenuItemClickListener(item -> { + resetBoxJSON(); + return false; }); - cancelNotif.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - @Override - public boolean onMenuItemClick(MenuItem item) { - try { - JSONObject localDataJson = null; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - localDataJson = new JSONObject(ProjectMacros.readFile(MainActivity.this, "localUserData.json")); - } - for (int i = 0; i < localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").length(); i++) { - JSONObject notificationObject = localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").getJSONObject(i); - ProjectMacros.cancelNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), R.raw.box_outline, "ALL_CHANNEL", MainActivity.this); - } - } catch (JSONException e) { - e.printStackTrace(); + cancelNotif.setOnMenuItemClickListener(item -> { + try { + JSONObject localDataJson = new JSONObject(ProjectMacros.readFile(MainActivity.this, "localUserData.json")); + for (int i = 0; i < localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").length(); i++) { + JSONObject notificationObject = localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").getJSONObject(i); + ProjectMacros.cancelNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), MainActivity.this); } - return false; + } catch (JSONException e) { + e.printStackTrace(); } + return false; }); + logOut.setOnMenuItemClickListener(item -> { + SharedPreferences savedSettings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); + SharedPreferences.Editor savedSettingsEditor = savedSettings.edit(); + + 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().logout().addOnCompleteListener(task ->{ + if(task.isSuccessful()){ + savedSettingsEditor.putBoolean("loggedIn", false); + savedSettingsEditor.apply(); + recreate(); + } + }); + return false; + }); return true; } - @SuppressLint("NewApi") - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @RequiresApi(api = Build.VERSION_CODES.N) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + SharedPreferences savedSettings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); + + askForPermAccess(Manifest.permission.INTERNET); + askForPermAccess(Manifest.permission.READ_EXTERNAL_STORAGE); + askForPermAccess(Manifest.permission.WRITE_EXTERNAL_STORAGE); + + if (!savedSettings.getBoolean("loggedIn", false)) { + if(savedSettings.getString("salt", "null").equals("null")){ + final Random r = new SecureRandom(); + byte[] salt = new byte[32]; + r.nextBytes(salt); + String encodedSalt = Base64.encode(salt); + SharedPreferences.Editor savedSettingsEditor = savedSettings.edit(); + savedSettingsEditor.putString("salt", encodedSalt); + savedSettingsEditor.apply(); + } + startActivityToRecreateOnExit(LoginActivity.class); + } + submitToast = new Toast(this); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - Objects.requireNonNull(getSupportActionBar()).setLogo(R.mipmap.ic_launcher); - } + Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true); + Objects.requireNonNull(getSupportActionBar()).setLogo(R.mipmap.ic_launcher); Objects.requireNonNull(getSupportActionBar()).setDisplayUseLogoEnabled(true); - askForWriteAccess(); - createSalt(); - checkLocalUserFile(); - checkNotifications(); - Button homeButton = findViewById(R.id.HomeHomeButton); - Button loginButton = findViewById(R.id.HomeLoginButton); - Button shopButton = findViewById(R.id.HomeShopButton); - Button experimentsButton = findViewById(R.id.HomeExperimentsButton); - Button progressButton = findViewById(R.id.HomeProgressButton); - Button aboutButton = findViewById(R.id.HomeAboutButton); - Button surveyButton = findViewById(R.id.HomeSurveyButton); - LinearLayout homeActLay = findViewById(R.id.HomeActivityLayout); - homeActLay.removeView(homeButton); - - Button testingButton = new Button(this); - String textViewTempText = "Developer"; - testingButton.setText(textViewTempText); - homeActLay.addView(testingButton); - testingButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startActivity(new Intent(MainActivity.this, TestingActivity.class)); - } - }); - try { - JSONObject localUserJSON = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - localUserJSON = new JSONObject(ProjectMacros.readFile(this, "localUserData.json")); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - d("dbg_testing", Objects.requireNonNull(localUserJSON).toString()); - } - assert localUserJSON != null; - if (localUserJSON.get("savedUserID") != JSONObject.NULL) { - d("dbg_test", "got user id"); - homeActLay.removeView(loginButton); - } else { - d("dbg_test", "do not got user id"); - homeActLay.removeAllViews(); - homeActLay.addView(loginButton); - } + Button logoutButton = new Button(this); + String logoutButtonText = "Logout"; + logoutButton.setText(logoutButtonText); + homeActLay.addView(logoutButton); + logoutButton.setOnClickListener(v -> { + SharedPreferences.Editor savedSettingsEditor = savedSettings.edit(); - if (localUserJSON.opt("locked") != JSONObject.NULL && localUserJSON.optBoolean("locked")) { - d("dbg_test", "is locked to experiment" + Objects.requireNonNull(localUserJSON.opt("locked")).toString()); - homeActLay.removeView(experimentsButton); + final StitchAppClient client; + if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){ + client = Stitch.getDefaultAppClient(); } else { - d("dbg_test", "is not locked to experiment"); - homeActLay.removeView(surveyButton); - + client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id)); } - } catch (JSONException e) { - e.printStackTrace(); - } - homeButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - d("dbg_testing", "When is this used?"); - } - }); + d("dbg_test_user_login", client.getAuth().getUser().getId()); - loginButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - intentTest = new Intent(MainActivity.this, LoginActivity.class); - startActivityForResult(intentTest, 0); - } + client.getAuth().logout().addOnCompleteListener(task ->{ + if(task.isSuccessful()){ + savedSettingsEditor.putBoolean("loggedIn", false); + savedSettingsEditor.apply(); + recreate(); + } + }); }); - shopButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - intentTest = new Intent(MainActivity.this, ShopActivity.class); - startActivity(intentTest); - } - }); + Button surveyButton = findViewById(R.id.HomeSurveyButton); + Button shopButton = findViewById(R.id.HomeShopButton); + shopButton.setOnClickListener(v -> startActivityToRecreateOnExit(ShopActivity.class)); + + Button experimentsButton = findViewById(R.id.HomeExperimentsButton); + experimentsButton.setOnClickListener(v -> { + mongoDBExperimentSync(); - experimentsButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - intentTest = new Intent(MainActivity.this, BoxesActivity.class); - startActivityForResult(intentTest, 0); - } }); + Button progressButton = findViewById(R.id.HomeProgressButton); + progressButton.setOnClickListener(v -> mongoDBUserSync()); - progressButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - intentTest = new Intent(MainActivity.this, ProgressActivity.class); - startActivity(intentTest); - } - }); + Button aboutButton = findViewById(R.id.HomeAboutButton); + aboutButton.setOnClickListener(v -> startActivityToRecreateOnExit(AboutActivity.class)); - aboutButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - intentTest = new Intent(MainActivity.this, AboutActivity.class); - startActivity(intentTest); - } - }); + surveyButton.setOnClickListener(v -> { + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kk:mm"); + String dateToday = simpleDateFormat.format(calendar.getTime()); - surveyButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Calendar calendar = Calendar.getInstance(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kk:mm"); - String dateToday = simpleDateFormat.format(calendar.getTime()); - - try { - JSONObject localUserJSON = null; - localUserJSON = new JSONObject(ProjectMacros.readFile(MainActivity.this, "localUserData.json")); - if (!localUserJSON.getJSONObject("lockedExperiment").optBoolean("SurveyQuestionTimeLock", false)) { - startActivity(new Intent(MainActivity.this, SurveyResponseActivity.class)); - } else if (ProjectMacros.compareTimes(dateToday, localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockToTime")) && ProjectMacros.compareTimes(localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockFromTime"), dateToday)){ - startActivity(new Intent(MainActivity.this, SurveyResponseActivity.class)); - } else { - ProjectMacros.showToast(submitToast, MainActivity.this, "It is not the time to answer the survey yet! Come back between " + localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockFromTime") + " and " + localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockToTime") + "."); - } - } catch (Exception e) { - e.printStackTrace(); + try { + JSONObject localUserJSON = new JSONObject(ProjectMacros.readFile(MainActivity.this, "localUserData.json")); + if (!localUserJSON.getJSONObject("lockedExperiment").optBoolean("SurveyQuestionTimeLock", false)) { + startActivity(new Intent(MainActivity.this, SurveyResponseActivity.class)); + } else if (ProjectMacros.compareTimes(dateToday, localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockToTime")) && ProjectMacros.compareTimes(localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockFromTime"), dateToday)){ + startActivity(new Intent(MainActivity.this, SurveyResponseActivity.class)); + } else { + ProjectMacros.showToast(submitToast, MainActivity.this, "It is not the time to answer the survey yet! Come back between " + localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockFromTime") + " and " + localUserJSON.getJSONObject("lockedExperiment").getString("SurveyQuestionTimeLockToTime") + "."); } + } catch (Exception e) { + e.printStackTrace(); } }); + + try { + JSONObject localUserJSON = new JSONObject(ProjectMacros.readFile(this, "localUserData.json")); + d("dbg_testing", Objects.requireNonNull(localUserJSON).toString()); + + if (localUserJSON.opt("locked") != JSONObject.NULL && localUserJSON.optBoolean("locked")) { + homeActLay.removeView(experimentsButton); + } else { + homeActLay.removeView(surveyButton); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void startActivityToRecreateOnExit(Class activity){ + recreateOnExitIntent = new Intent(MainActivity.this, activity); + startActivityForResult(recreateOnExitIntent, 0); } @RequiresApi(api = Build.VERSION_CODES.KITKAT) @@ -235,124 +223,37 @@ public class MainActivity extends AppCompatActivity { JSONObject notificationObject = localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").getJSONObject(i); Calendar start = Calendar.getInstance(); - start.set(Calendar.HOUR_OF_DAY, Integer.parseInt(notificationObject.getString("Time").substring(0,2))); + start.set(Calendar.HOUR, Integer.parseInt(notificationObject.getString("Time").substring(0,2))); start.set(Calendar.MINUTE, Integer.parseInt(notificationObject.getString("Time").substring(3,5))); start.set(Calendar.SECOND, 0); start.set(Calendar.MILLISECOND, 0); - d("dbg_timesNstuff", notificationObject.getString("Time").substring(0,2) + " hours /" + notificationObject.getString("Time").substring(3,5) + " minutes"); Calendar repeat = Calendar.getInstance(); - repeat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(notificationObject.getString("Repeat").substring(0,2))); + repeat.set(Calendar.HOUR, Integer.parseInt(notificationObject.getString("Repeat").substring(0,2))); repeat.set(Calendar.MINUTE, Integer.parseInt(notificationObject.getString("Repeat").substring(3,5))); repeat.set(Calendar.SECOND, 0); repeat.set(Calendar.MILLISECOND, 0); - d("dbg_timesNstuff", notificationObject.getString("Repeat").substring(0,2) + " hours /" + notificationObject.getString("Repeat").substring(3,5) + " minutes"); - - ProjectMacros.createNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), R.raw.box_outline, "ALL_CHANNEL", MainActivity.this, start, repeat); + ProjectMacros.createNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), MainActivity.this, start, repeat); } } else { - d("dbg_checkNotifs", "not locked"); for(int i = 0; i < localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").length(); i++){ JSONObject notificationObject = localDataJson.getJSONObject("lockedExperiment").getJSONArray("Notification").getJSONObject(i); - ProjectMacros.cancelNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), R.raw.box_outline, "ALL_CHANNEL", MainActivity.this); + ProjectMacros.cancelNotification(notificationObject.getString("Title"), notificationObject.getString("Message"), MainActivity.this); } } } catch (JSONException e) { e.printStackTrace(); } - - } - - private void checkLocalUserFile() { - File file = new File(this.getFilesDir(), "localUserData.json"); - if (!file.exists()) { - // Do stuff to initialise the file - InputStream inputStream = getResources().openRawResource(R.raw.local_user_data); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - String localUserData = ""; - int ctr; - try { - ctr = inputStream.read(); - while (ctr != -1) { - byteArrayOutputStream.write(ctr); - ctr = inputStream.read(); - } - inputStream.close(); - - localUserData = byteArrayOutputStream.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - - - ProjectMacros.saveFile(this, "localUserData.json", localUserData); - } - } - - private void createSalt() { - SharedPreferences savedSettings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); - SharedPreferences.Editor savedSettingsEditor = savedSettings.edit(); - - if (savedSettings.getString("salt", "").equals("")) { - Random saltGenerator = new Random(); - StringBuilder saltString = new StringBuilder(); - Character iterativeCharacter; - - for (int i = 0; i < 10; i++) { - iterativeCharacter = Integer.toString(saltGenerator.nextInt(96) + 32).charAt(0); - saltString.append(iterativeCharacter); - } - - savedSettingsEditor.putString("Salt", saltString.toString()); - savedSettingsEditor.apply(); - } else { - d("dbg_Salt", savedSettings.getString("Salt", "")); - } } @RequiresApi(api = Build.VERSION_CODES.KITKAT) private void resetBoxJSON() { - // Load Box Json and initialise to internal storage - InputStream inputStream = getResources().openRawResource(R.raw.box); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - String boxesData = ""; - int ctr; - try { - ctr = inputStream.read(); - while (ctr != -1) { - byteArrayOutputStream.write(ctr); - ctr = inputStream.read(); - } - inputStream.close(); - - boxesData = byteArrayOutputStream.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - - ProjectMacros.saveFile(this, "boxData.json", boxesData); - - inputStream = getResources().openRawResource(R.raw.local_user_data); - byteArrayOutputStream = new ByteArrayOutputStream(); - String localUserData = ""; - try { - ctr = inputStream.read(); - while (ctr != -1) { - byteArrayOutputStream.write(ctr); - ctr = inputStream.read(); - } - inputStream.close(); - - localUserData = byteArrayOutputStream.toString(); - } catch (Exception e) { - e.printStackTrace(); - } + String localUserData = ProjectMacros.readRaw(R.raw.local_user_data, this); + String boxData = ProjectMacros.readRaw(R.raw.box, this); ProjectMacros.saveFile(this, "localUserData.json", localUserData); - - d("dbg_file", ProjectMacros.readFile(this, "boxData.json")); d("dbg_file", ProjectMacros.readFile(this, "localUserData.json")); recreate(); @@ -363,6 +264,7 @@ public class MainActivity extends AppCompatActivity { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0) { shouldRecreate = true; + recreate(); } } @@ -382,97 +284,106 @@ public class MainActivity extends AppCompatActivity { } } - // Image permission check - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - private void askForWriteAccess() { - if (ContextCompat.checkSelfPermission(MainActivity.this, - Manifest.permission.INTERNET) - != PackageManager.PERMISSION_GRANTED) { + private void mongoDBExperimentSync() { + final StitchAppClient client; - if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, - Manifest.permission.INTERNET)) { - - AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); - builder.setTitle("Permission Required") - .setMessage("Permission to access internet for login.") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", getPackageName(), null)); - startActivityForResult(intent, 5); - } - }).setNegativeButton("Cancel", null).show(); - - } else { - ActivityCompat.requestPermissions(MainActivity.this, - new String[]{Manifest.permission.INTERNET}, - 1); - } + if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){ + client = Stitch.getDefaultAppClient(); } else { - d("dbg_Perm", "Already granted"); + client = Stitch.initializeDefaultAppClient(getString(R.string.mongo_stitch_id)); } - - if (ContextCompat.checkSelfPermission(MainActivity.this, - Manifest.permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - - if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, - Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - - AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); - builder.setTitle("Permission Required") - .setMessage("Permission to device storage is required for image upload.") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", getPackageName(), null)); - startActivityForResult(intent, 5); + final RemoteMongoClient mongoClient = client.getServiceClient(RemoteMongoClient.factory, "XBF"); + final RemoteMongoCollection<Document> coll = mongoClient.getDatabase("IPServer").getCollection("Experiments"); + + client.getAuth().addAuthListener(auth -> { + if(auth.isLoggedIn()){ + List<Document> docs = new ArrayList<>(); + coll.find(new Document("Approved", true)).into(docs).addOnCompleteListener(findTask->{ + if(findTask.isSuccessful()){ + JSONArray boxes = new JSONArray(); + for(int i = 0; i < findTask.getResult().size(); i++){ + try { + boxes.put(new JSONObject(findTask.getResult().get(i).toJson())); + } catch (JSONException e) { + e.printStackTrace(); } - }).setNegativeButton("Cancel", null).show(); - - } else { - ActivityCompat.requestPermissions(MainActivity.this, - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - 1); + } + d("dbg_boxes", boxes.toString()); + + findTask.addOnCompleteListener(completedTask->{ + ProjectMacros.saveFile(MainActivity.this,"boxData.json", boxes.toString()); + }).addOnCompleteListener(completedTask->{ + startActivityToRecreateOnExit(BoxesActivity.class); + }); + } + }); } + }); + } + + private void mongoDBUserSync() { + final StitchAppClient client; + + if(Stitch.hasAppClient(getString(R.string.mongo_stitch_id))){ + client = Stitch.getDefaultAppClient(); } else { - d("dbg_Perm", "Already granted"); + 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()){ + List<Document> docs = new ArrayList<>(); + coll.find(new Document("owner_id", auth.getUser().getId())).into(docs).addOnCompleteListener(findTask->{ + if(findTask.isSuccessful()){ + JSONObject localUserData = new JSONObject(); + try { + localUserData = new JSONObject(findTask.getResult().get(0).toJson()); + } catch (JSONException e) { + e.printStackTrace(); + } + + d("dbg_boxes", localUserData.toString()); + JSONObject finalLocalUserData = localUserData; + findTask.addOnCompleteListener(completedTask->{ + ProjectMacros.saveFile(MainActivity.this,"localUserData.json", finalLocalUserData.toString()); + }).addOnCompleteListener(completedTask->{ + startActivityToRecreateOnExit(ProgressActivity.class); + }); + } + }); + } + }); + } + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + private void askForPermAccess(String permission) { if (ContextCompat.checkSelfPermission(MainActivity.this, - Manifest.permission.READ_EXTERNAL_STORAGE) + permission) != PackageManager.PERMISSION_GRANTED) { - if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, - Manifest.permission.READ_EXTERNAL_STORAGE)) { + if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, permission)) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Permission Required") - .setMessage("Permission to device storage is required for image upload.") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", getPackageName(), null)); - startActivityForResult(intent, 5); - } + .setMessage("Permission to access internet for login.") + .setPositiveButton("Ok", (dialog, which) -> { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.fromParts("package", getPackageName(), null)); + startActivityForResult(intent, 5); }).setNegativeButton("Cancel", null).show(); } else { ActivityCompat.requestPermissions(MainActivity.this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + new String[]{permission}, 1); } } else { d("dbg_Perm", "Already granted"); } } - - } \ No newline at end of file diff --git a/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java b/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java index 9e44d6cd6a59b26755ca5ebf8e2f8cb698abcd1b..6645f711be35e539888c8b7a9a65ac08af7af995 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java @@ -1,7 +1,7 @@ package com.yearthreeproject.xbframework; import android.Manifest; -import android.content.DialogInterface; +import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; @@ -33,6 +33,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.theartofdev.edmodo.cropper.CropImage; import com.theartofdev.edmodo.cropper.CropImageView; @@ -96,6 +97,7 @@ public class NewBox extends AppCompatActivity { final Spinner inFiveSpinner = findViewById(R.id.MEECSSpinner); ArrayAdapter<CharSequence> inFiveAdapter = ArrayAdapter.createFromResource(this, R.array.meecs, android.R.layout.simple_spinner_dropdown_item); inFiveSpinner.setAdapter(inFiveAdapter); + inFiveSpinner.setSelection(inFiveAdapter.getPosition(inFiveValue)); inFiveSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { @@ -108,12 +110,7 @@ public class NewBox extends AppCompatActivity { } }); uploadImageButton.setMaxHeight(uploadImageButton.getHeight()); - uploadImageButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - imagePermissionCheckFunction(); - } - }); + uploadImageButton.setOnClickListener(v -> imagePermissionCheckFunction()); final LinearLayout scrollLayout = findViewById(R.id.InputDataScrollableLayout); @@ -125,30 +122,21 @@ public class NewBox extends AppCompatActivity { scrollLayout.addView(addNewGroupButton); - addNewGroupButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - scrollLayout.removeView(v); - scrollLayout.addView(addGroupFunction(++globalGroupIndex)); - scrollLayout.addView(v); - d("dbg_numOfGroupTitles", String.valueOf(groupTitlesArray.size())); - } + addNewGroupButton.setOnClickListener(v -> { + scrollLayout.removeView(v); + scrollLayout.addView(addGroupFunction(++globalGroupIndex)); + scrollLayout.addView(v); + d("dbg_numOfGroupTitles", String.valueOf(groupTitlesArray.size())); }); - Button submit = findViewById(R.id.NewBoxSubmitButton); - submit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - submitNewBoxFunction(); - } - }); + FloatingActionButton submitFAB = findViewById(R.id.NewBoxSubmitFAB); + submitFAB.setOnClickListener(v -> submitNewBoxFunction()); } private void submitNewBoxFunction() { boolean completedInfo = true; 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++) { if (groupTitlesArray.get(i).getText().toString().matches("")) { completedInfo = false; @@ -212,7 +200,7 @@ public class NewBox extends AppCompatActivity { tempEditTextForStringRetrieval = findViewById(R.id.BlurbEditText); 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); else box.put("Image", JSONObject.NULL); @@ -248,7 +236,7 @@ public class NewBox extends AppCompatActivity { openPage.putExtra("JSON", box.toString()); openPage.putExtra("ExperimentIndex", 0); openPage.putExtra("GroupIndex", 0); - d("dbg_json", box.toString()); + startActivity(openPage); } catch (JSONException e) { e.printStackTrace(); @@ -270,14 +258,11 @@ public class NewBox extends AppCompatActivity { AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this); builder.setTitle("Permission Required") .setMessage("Permission to device storage is required for image upload.") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", getPackageName(), null)); - startActivityForResult(intent, 5); - } + .setPositiveButton("Ok", (dialog, which) -> { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.fromParts("package", getPackageName(), null)); + startActivityForResult(intent, 5); }).setNegativeButton("Cancel", null).show(); } else { @@ -291,6 +276,7 @@ public class NewBox extends AppCompatActivity { } } + @SuppressLint("ResourceType") private LinearLayout addGroupFunction(final int localGroupIndex) { final LinearLayout linearGroupLayout = new LinearLayout(this); linearGroupLayout.setOrientation(LinearLayout.VERTICAL); @@ -346,48 +332,40 @@ public class NewBox extends AppCompatActivity { relativeGroupLayout.addView(deleteGroupButton, deleteGroupButtonAlignment); groupTitlesArray.add(titleEditText); - experimentTitlesArray.add(new ArrayList<EditText>()); - experimentDescriptionsArray.add(new ArrayList<EditText>()); - experimentInstructionsArray.add(new ArrayList<EditText>()); - - addExperimentToGroupButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - LinearLayout parent = (LinearLayout) v.getParent(); - parent.removeView(v); - linearGroupLayout.addView(addExperimentFunction(localGroupIndex)); - parent.addView(v); - } + experimentTitlesArray.add(new ArrayList<>()); + experimentDescriptionsArray.add(new ArrayList<>()); + experimentInstructionsArray.add(new ArrayList<>()); + + addExperimentToGroupButton.setOnClickListener(v -> { + LinearLayout parent = (LinearLayout) v.getParent(); + parent.removeView(v); + linearGroupLayout.addView(addExperimentFunction(localGroupIndex)); + parent.addView(v); }); - deleteGroupButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - AlertDialog.Builder al = new AlertDialog.Builder(NewBox.this); - al.setTitle("Are you sure?") - .setMessage("Are you sure you want to delete this group?") - .setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - linearGroupLayout.removeAllViews(); - groupTitlesArray.remove(titleEditText); - experimentTitlesArray.remove(localGroupIndex); - experimentDescriptionsArray.remove(localGroupIndex); - experimentInstructionsArray.remove(localGroupIndex); - globalGroupIndex--; - } - }).setNegativeButton("No", null) - .show(); - } + deleteGroupButton.setOnClickListener(v -> { + AlertDialog.Builder al = new AlertDialog.Builder(NewBox.this); + al.setTitle("Are you sure?") + .setMessage("Are you sure you want to delete this group?") + .setPositiveButton("Yes", (dialog, which) -> { + linearGroupLayout.removeAllViews(); + groupTitlesArray.remove(titleEditText); + experimentTitlesArray.remove(localGroupIndex); + experimentDescriptionsArray.remove(localGroupIndex); + experimentInstructionsArray.remove(localGroupIndex); + globalGroupIndex--; + }).setNegativeButton("No", null) + .show(); }); linearGroupLayout.addView(relativeGroupLayout); linearGroupLayout.addView(addExperimentToGroupButton); - linearGroupLayout.addView(ProjectMacros.newHR(this, 4, "#888888")); + linearGroupLayout.addView(ProjectMacros.newHR(this, 4, getString(R.color.colorPrimary))); return linearGroupLayout; } + @SuppressLint("ResourceType") private RelativeLayout addExperimentFunction(final int localGroupIndex) { final RelativeLayout experimentRelativeLayout = new RelativeLayout(this); @@ -467,32 +445,24 @@ public class NewBox extends AppCompatActivity { experimentRelativeLayout.addView(experimentDescriptionTextView, experimentDescriptionTextViewAlignment); experimentRelativeLayout.addView(experimentInstructionsEditText, experimentInstructionsEditTextAlignment); 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); textViewTempText = "x"; deleteExperimentButton.setText(textViewTempText); - deleteExperimentButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ViewGroup deleteExperimentButtonParent = (ViewGroup) v.getParent(); - experimentTitlesArray.get(localGroupIndex).remove(experimentTitleEditText); - experimentDescriptionsArray.get(localGroupIndex).remove(experimentDescriptionEditText); - experimentInstructionsArray.get(localGroupIndex).remove(experimentInstructionsEditText); - experimentRelativeLayout.removeAllViews(); - deleteExperimentButtonParent.removeView(v); - } + deleteExperimentButton.setOnClickListener(v -> { + ViewGroup deleteExperimentButtonParent = (ViewGroup) v.getParent(); + experimentTitlesArray.get(localGroupIndex).remove(experimentTitleEditText); + experimentDescriptionsArray.get(localGroupIndex).remove(experimentDescriptionEditText); + experimentInstructionsArray.get(localGroupIndex).remove(experimentInstructionsEditText); + experimentRelativeLayout.removeAllViews(); + deleteExperimentButtonParent.removeView(v); }); final Button addAnotherExperimentButton = new Button(NewBox.this); textViewTempText = "Add Experiment"; addAnotherExperimentButton.setText(textViewTempText); - addAnotherExperimentButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - addExperimentFunction(localGroupIndex); - } - }); + addAnotherExperimentButton.setOnClickListener(v -> addExperimentFunction(localGroupIndex)); RelativeLayout.LayoutParams deleteExperimentButtonAlignment = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); deleteExperimentButtonAlignment.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); @@ -503,7 +473,6 @@ public class NewBox extends AppCompatActivity { 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 public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); @@ -528,7 +497,7 @@ public class NewBox extends AppCompatActivity { @Override public void onRequestPermissionsResult(int requestCode, @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 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { d("dbg_Perm", "granted"); @@ -537,14 +506,11 @@ public class NewBox extends AppCompatActivity { AlertDialog.Builder builder = new AlertDialog.Builder(NewBox.this); builder.setTitle("Permission Required") .setMessage("Permission to device storage is required for image upload.") - .setPositiveButton("Ok", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", getPackageName(), null)); - startActivityForResult(intent, 5); - } + .setPositiveButton("Ok", (dialog, which) -> { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.fromParts("package", getPackageName(), null)); + startActivityForResult(intent, 5); }).setNegativeButton("Cancel", null).show(); } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java index 2d9c263542a3b6989727be61d0197a995d2b16b3..c3d469b88bb2e36be465cb770ec85d062be5a1d8 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java @@ -1,13 +1,15 @@ package com.yearthreeproject.xbframework; +import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.os.Build; import android.os.Bundle; import android.text.Html; -import android.view.View; +import android.util.Log; import android.view.ViewGroup; import android.widget.EditText; import android.widget.LinearLayout; @@ -31,7 +33,14 @@ import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.DataPointInterface; import com.jjoe64.graphview.series.LineGraphSeries; import com.jjoe64.graphview.series.PointsGraphSeries; - +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.auth.providers.userpassword.UserPasswordCredential; +import com.mongodb.stitch.core.services.mongodb.remote.RemoteUpdateOptions; + +import org.bson.Document; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -80,6 +89,8 @@ public class ProgressActivity extends AppCompatActivity { JSONArray journalArray; + int latestExperimentColor; + @Override public boolean onSupportNavigateUp() { @@ -106,12 +117,7 @@ public class ProgressActivity extends AppCompatActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); - toolbar.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - findViewById(R.id.progressScrollObject).scrollTo(0,0); - } - }); + toolbar.setOnClickListener(v -> findViewById(R.id.progressScrollObject).scrollTo(0,0)); final LinearLayout mainBody = findViewById(R.id.progressScrollLinLay); @@ -121,78 +127,85 @@ public class ProgressActivity extends AppCompatActivity { try { localUserData = new JSONObject(ProjectMacros.readFile(this, "localUserData.json")); - currentExperimentData = localUserData.getJSONObject("lockedExperiment").getJSONArray("UserData"); + currentExperimentData = localUserData.getJSONObject("lockedExperiment").optJSONArray("UserData"); archivedExperimentData = localUserData.getJSONArray("archivedExperimentData"); journalArray = localUserData.getJSONArray("journal"); - } catch (JSONException e) { - e.printStackTrace(); - } - // Setup calendarView - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - generateGraphCalendar(calendarView); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + generateGraphCalendar(calendarView); + } - Calendar cal = Calendar.getInstance(); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.HOUR, 0); - cal.set(Calendar.MILLISECOND, 0); + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.HOUR, 0); + cal.set(Calendar.MILLISECOND, 0); - long lowest = cal.getTime().getTime(); + long lowest = cal.getTime().getTime(); - try{ if(localUserData.getBoolean("locked")) generateCurrentExperimentGraph(calendarView); String experimentName; - if(currentExperimentData.length() != 0 || archivedExperimentData.length() != 0){ - List<DataPoint> dataSeries; - - if(localUserData.getBoolean("locked") && currentExperimentData.length() > 1){ - experimentName = localUserData.getJSONObject("lockedExperiment").getString("Title"); - dataSeries = loopJSONArrayForPoints(currentExperimentData, new ArrayList<DataPoint>()); - lowest = loopJSONArrayForLowest(currentExperimentData, lowest); - } else { - long highest = cal.getTime().getTime(); - int highestIndex = 0; - - for(int i = 0; i < archivedExperimentData.length(); i++){ - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(0, 2))); - cal.set(Calendar.MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(3, 5)) - 1); - cal.set(Calendar.YEAR, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(6, 10))); - long calNow = cal.getTime().getTime(); - if (i == 0 || calNow >= highest) { - highest = calNow; - highestIndex = i; + if(currentExperimentData != null && archivedExperimentData != null){ + if(currentExperimentData.length() != 0 || archivedExperimentData.length() != 0){ + List<DataPoint> dataSeries; + + if(localUserData.getBoolean("locked") && currentExperimentData.length() > 1){ + experimentName = localUserData.getJSONObject("lockedExperiment").getString("Title"); + dataSeries = loopJSONArrayForPoints(currentExperimentData, new ArrayList<DataPoint>()); + lowest = loopJSONArrayForLowest(currentExperimentData, lowest); + } else { + long highest = cal.getTime().getTime(); + int highestIndex = 0; + + for(int i = 0; i < archivedExperimentData.length(); i++){ + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(0, 2))); + cal.set(Calendar.MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(3, 5)) - 1); + cal.set(Calendar.YEAR, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(6, 10))); + long calNow = cal.getTime().getTime(); + if (i == 0 || calNow >= highest) { + highest = calNow; + highestIndex = i; + } } - } - experimentName = archivedExperimentData.getJSONObject(highestIndex).getString("Experiment"); + experimentName = archivedExperimentData.getJSONObject(highestIndex).getString("Experiment"); - dataSeries = arrayLoopForSelectedDateForData(archivedExperimentData, new ArrayList<DataPoint>(), experimentName); - lowest = arrayLoopForSelectedDateForLowest(archivedExperimentData, lowest, experimentName); + dataSeries = arrayLoopForSelectedDateForData(archivedExperimentData, new ArrayList<DataPoint>(), experimentName); + lowest = arrayLoopForSelectedDateForLowest(archivedExperimentData, lowest, experimentName); - oldDateGraph = new Date(highest); - final SimpleDateFormat dateFormatForMonth = new SimpleDateFormat("MMM - yyyy", Locale.getDefault()); - calendarViewForGraphs.setCurrentDate(oldDateGraph); - monthTextViewGraph.setText(dateFormatForMonth.format(calendarViewForGraphs.getFirstDayOfCurrentMonth())); - } - DataPoint[] series = new DataPoint[0]; - if (dataSeries != null) { - series = new DataPoint[dataSeries.size()]; - } + oldDateGraph = new Date(highest); + final SimpleDateFormat dateFormatForMonth = new SimpleDateFormat("MMM - yyyy", Locale.getDefault()); + calendarViewForGraphs.setCurrentDate(oldDateGraph); + monthTextViewGraph.setText(dateFormatForMonth.format(calendarViewForGraphs.getFirstDayOfCurrentMonth())); + } + DataPoint[] series = new DataPoint[0]; + if (dataSeries != null) { + series = new DataPoint[dataSeries.size()]; + } - if (dataSeries != null) { - for (int i = 0; i < dataSeries.size(); i++) series[i] = dataSeries.get(i); - } + if (dataSeries != null) { + for (int i = 0; i < dataSeries.size(); i++) series[i] = dataSeries.get(i); + } - generateSelectedGraph(calendarView, series, lowest); + generateSelectedGraph(calendarView, series, lowest); - String selectedGraphString = "Experiment: " + experimentName; - selectedGraphTitle.setText(selectedGraphString); + String selectedGraphString = "Experiment: " + experimentName; + selectedGraphTitle.setText(selectedGraphString); - generateOverallGraph(calendarView); + generateOverallGraph(calendarView); + } else { + TextView noDataMessage = new TextView(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + noDataMessage.setTextColor(getColor(R.color.colorPrimary)); + } + noDataMessage.setTextSize(30); + noDataMessage.setText(Html.fromHtml("There has been no experiment data to show yet!")); + calendarView.addView(noDataMessage); + } } else { + oldDateGraph = new Date(); + oldDateJournal = new Date(); TextView noDataMessage = new TextView(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { noDataMessage.setTextColor(getColor(R.color.colorPrimary)); @@ -201,30 +214,25 @@ public class ProgressActivity extends AppCompatActivity { noDataMessage.setText(Html.fromHtml("There has been no experiment data to show yet!")); calendarView.addView(noDataMessage); } - } catch (JSONException e){ - e.printStackTrace(); - } - // Setup Journal View - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - generateJournalCalendar(journalView); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + generateJournalCalendar(journalView); + } journalView.addView(ProjectMacros.newHR(this, 10,"#587B7F")); generateJournalTodaysEntry(journalView); journalView.addView(ProjectMacros.newHR(this, 10,"#587B7F")); generateJournalSelectedEntry(journalView); journalView.addView(ProjectMacros.newHR(this, 10,"#587B7F")); generateJournalExperimentEntries(journalView, ""); - } - final FloatingActionButton journalFAB = findViewById(R.id.editCurrentJournal); - final ViewGroup coordinateLayout = findViewById(R.id.mainScreen); - coordinateLayout.removeView(journalFAB); - mainBody.removeView(journalView); + final FloatingActionButton journalFAB = findViewById(R.id.editCurrentJournal); + final ViewGroup coordinateLayout = findViewById(R.id.mainScreen); - journalFAB.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { + coordinateLayout.removeView(journalFAB); + mainBody.removeView(journalView); + + journalFAB.setOnClickListener(view -> { AlertDialog.Builder alert = new AlertDialog.Builder(ProgressActivity.this, R.style.AlertDialogStyle); alert.setTitle("Today's Journal Entry"); @@ -245,12 +253,12 @@ public class ProgressActivity extends AppCompatActivity { try{ JSONArray journalEntriesOut = new JSONArray(); - Calendar cal = Calendar.getInstance(); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.HOUR, 0); - Date today = cal.getTime(); + Calendar cal1 = Calendar.getInstance(); + cal1.set(Calendar.MILLISECOND, 0); + cal1.set(Calendar.SECOND, 0); + cal1.set(Calendar.MINUTE, 0); + cal1.set(Calendar.HOUR, 0); + Date today = cal1.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY", Locale.getDefault()); for(int i = 0; i < journalArray.length(); i++){ @@ -262,10 +270,41 @@ public class ProgressActivity extends AppCompatActivity { if(sdf.format(oldDateJournal).equals(sdf.format(today))){ selectedEntryTitle.setText(Html.fromHtml(localUserData.getJSONObject("lockedExperiment").getString("Title") + " (" + sdf.format(today) + "):")); selectedEntryText.setText(todaysEntryText.getText().toString()); + } localUserData.put("journal", journalEntriesOut); ProjectMacros.saveFile(ProgressActivity.this, "localUserData.json", localUserData.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(localUserData.toString()) + .append("owner_id", auth.getUser().getId()), + new RemoteUpdateOptions().upsert(true)).addOnCompleteListener(task1->{ + try { + calendarViewForJournal.addEvent(new Event(latestExperimentColor, cal1.getTimeInMillis(), localUserData.getJSONObject("lockedExperiment").getString("Title"))); + } catch (JSONException e) { + e.printStackTrace(); + } + d("dbg_was_succesful", String.valueOf(task1.isSuccessful())); + d("dbg_storedJSON", localUserData.toString()); + }); + } + }); + + } catch (JSONException e){ e.printStackTrace(); } @@ -274,26 +313,28 @@ public class ProgressActivity extends AppCompatActivity { try{ JSONArray journalEntriesOut = new JSONArray(); - Calendar cal = Calendar.getInstance(); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.HOUR, 0); - Date today = cal.getTime(); + Calendar cal1 = Calendar.getInstance(); + cal1.set(Calendar.MILLISECOND, 0); + cal1.set(Calendar.SECOND, 0); + cal1.set(Calendar.MINUTE, 0); + cal1.set(Calendar.HOUR, 0); + Date today = cal1.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY", Locale.getDefault()); boolean todayExists = false; - for(int i = 0; i < journalArray.length(); i++){ - if(sdf.format(today).equals(journalArray.getJSONObject(i).getString("Date"))){ - todayExists = true; - JSONObject tempObject = new JSONObject(); - tempObject.put("Date", sdf.format(today)); - tempObject.put("Experiment", localUserData.getJSONObject("lockedExperiment").getString("Title")); - tempObject.put("Entry", input.getText()); - journalEntriesOut.put(tempObject); - } else { - journalEntriesOut.put(journalArray.getJSONObject(i)); + if(journalArray != null){ + for(int i = 0; i < journalArray.length(); i++){ + if(sdf.format(today).equals(journalArray.getJSONObject(i).getString("Date"))){ + todayExists = true; + JSONObject tempObject = new JSONObject(); + tempObject.put("Date", sdf.format(today)); + tempObject.put("Experiment", localUserData.getJSONObject("lockedExperiment").getString("Title")); + tempObject.put("Entry", input.getText()); + journalEntriesOut.put(tempObject); + } else { + journalEntriesOut.put(journalArray.getJSONObject(i)); + } } } @@ -302,7 +343,7 @@ public class ProgressActivity extends AppCompatActivity { tempObject.put("Date", sdf.format(today)); tempObject.put("Experiment", localUserData.getJSONObject("lockedExperiment").getString("Title")); tempObject.put("Entry", input.getText()); - journalEntriesOut.put(tempObject); + journalEntriesOut.put(journalEntriesOut.length()-1, tempObject); } if(sdf.format(oldDateJournal).equals(sdf.format(today))){ @@ -312,11 +353,39 @@ public class ProgressActivity extends AppCompatActivity { localUserData.put("journal", journalEntriesOut); ProjectMacros.saveFile(ProgressActivity.this, "localUserData.json", localUserData.toString()); - } catch (JSONException e) { + + + 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 = ProgressActivity.this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); + + client.getAuth().loginWithCredential(new UserPasswordCredential(savedSettings.getString("email", "invalid"), savedSettings.getString("password", "invalid"))).addOnCompleteListener(task -> { + if (task.isSuccessful()) { + Log.d("stitch", "Successfully logged in as user " + task.getResult().getId()); + } + }).addOnCompleteListener(task->{ + coll.updateOne( + new Document("owner_id", savedSettings.getString("ownerId", "invalid")), + Document.parse(localUserData.toString()) + .append("owner_id", savedSettings.getString("ownerId", "invalid")), + new RemoteUpdateOptions().upsert(true)).addOnCompleteListener(task1->{ + d("dbg_was_succesful", String.valueOf(task1.isSuccessful())); + d("dbg_storedJSON", localUserData.toString()); + }); + }); + + } catch (JSONException e) { e.printStackTrace(); } } - }}); + }}); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { @@ -325,46 +394,50 @@ public class ProgressActivity extends AppCompatActivity { }); alert.show(); - } - }); + }); - // Tab layout setup, with calendarView being set as default - TabLayout tabLay = findViewById(R.id.tabs); - tabLay.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { - @Override - public void onTabSelected(TabLayout.Tab tab) { - switch(tab.getPosition()){ - case 0: - if(mainBody.getChildAt(0) == journalView) { - mainBody.removeView(journalView); - coordinateLayout.removeView(journalFAB); - } - if(mainBody.getChildAt(0) != calendarView) mainBody.addView(calendarView); - findViewById(R.id.progressScrollObject).scrollTo(0,0); - break; - case 1: - if(mainBody.getChildAt(0) == calendarView) mainBody.removeView(calendarView); - if(mainBody.getChildAt(0) != journalView) { - mainBody.addView(journalView); - coordinateLayout.addView(journalFAB); - } - findViewById(R.id.progressScrollObject).scrollTo(0,0); - break; - default: - d("dbg_error", "no correct tab selected"); + // Tab layout setup, with calendarView being set as default + TabLayout tabLay = findViewById(R.id.tabs); + tabLay.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + switch(tab.getPosition()){ + case 0: + if(mainBody.getChildAt(0) == journalView) { + mainBody.removeView(journalView); + coordinateLayout.removeView(journalFAB); + } + if(mainBody.getChildAt(0) != calendarView) mainBody.addView(calendarView); + findViewById(R.id.progressScrollObject).scrollTo(0,0); + break; + case 1: + if(mainBody.getChildAt(0) == calendarView) mainBody.removeView(calendarView); + if(mainBody.getChildAt(0) != journalView) { + mainBody.addView(journalView); + coordinateLayout.addView(journalFAB); + } + findViewById(R.id.progressScrollObject).scrollTo(0,0); + break; + default: + d("dbg_error", "no correct tab selected"); + } } - } - @Override - public void onTabUnselected(TabLayout.Tab tab) { + @Override + public void onTabUnselected(TabLayout.Tab tab) { - } + } - @Override - public void onTabReselected(TabLayout.Tab tab) { + @Override + public void onTabReselected(TabLayout.Tab tab) { - } - }); + } + }); + + + } catch (JSONException e) { + e.printStackTrace(); + } } @RequiresApi(api = Build.VERSION_CODES.KITKAT) @@ -375,7 +448,7 @@ public class ProgressActivity extends AppCompatActivity { try { - if (localUserData.getBoolean("locked")) { + if (localUserData.getBoolean("locked") && journalArray != null) { for (int i = 0; i < journalArray.length(); i++) { if (journalArray.getJSONObject(i).getString("Experiment").equals(localUserData.getJSONObject("lockedExperiment").getString("Title"))){ LinearLayout tempLayout = new LinearLayout(this); @@ -417,40 +490,41 @@ public class ProgressActivity extends AppCompatActivity { } else { experimentJournalLayout.removeAllViews(); try { - for (int i = 0; i < journalArray.length(); i++) { - if (journalArray.getJSONObject(i).getString("Experiment").equals(experiment)) { - LinearLayout tempLayout = new LinearLayout(this); - tempLayout.setOrientation(LinearLayout.VERTICAL); - TextView tempTitle = new TextView(this); - TextView tempEntry = new TextView(this); - - Calendar cal = Calendar.getInstance(); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.HOUR, 0); - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(0,2))); - cal.set(Calendar.MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(3,5))-1); - cal.set(Calendar.YEAR, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(6,10))); - Date dateValue = cal.getTime(); - - SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/YYYY", Locale.getDefault()); - - tempTitle.setText(Html.fromHtml(experiment + " (" + sdf.format(dateValue) + "):")); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - tempTitle.setTextColor(getColor(R.color.colorPrimary)); - } - tempTitle.setTextSize(20); - tempEntry.setText(Html.fromHtml(journalArray.getJSONObject(i).getString("Entry"))); + if(journalArray != null){ + for (int i = 0; i < journalArray.length(); i++) { + if (journalArray.getJSONObject(i).getString("Experiment").equals(experiment)) { + LinearLayout tempLayout = new LinearLayout(this); + tempLayout.setOrientation(LinearLayout.VERTICAL); + TextView tempTitle = new TextView(this); + TextView tempEntry = new TextView(this); + + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MILLISECOND, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.HOUR, 0); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(0,2))); + cal.set(Calendar.MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(3,5))-1); + cal.set(Calendar.YEAR, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(6,10))); + Date dateValue = cal.getTime(); + + SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/YYYY", Locale.getDefault()); + + tempTitle.setText(Html.fromHtml(experiment + " (" + sdf.format(dateValue) + "):")); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + tempTitle.setTextColor(getColor(R.color.colorPrimary)); + } + tempTitle.setTextSize(20); + tempEntry.setText(Html.fromHtml(journalArray.getJSONObject(i).getString("Entry"))); - tempLayout.addView(tempTitle); - tempLayout.addView(tempEntry); - tempLayout.addView(ProjectMacros.newHR(this, 4, "#587B7F")); + tempLayout.addView(tempTitle); + tempLayout.addView(tempEntry); + tempLayout.addView(ProjectMacros.newHR(this, 4, "#587B7F")); - experimentJournalLayout.addView(tempLayout); + experimentJournalLayout.addView(tempLayout); + } } } - } catch (JSONException e) { e.printStackTrace(); } @@ -519,10 +593,12 @@ public class ProgressActivity extends AppCompatActivity { sdf = new SimpleDateFormat("dd/MM/YYYY", Locale.getDefault()); - for(int i = 0; i < journalArray.length(); i++){ - if(sdf.format(today).equals(journalArray.getJSONObject(i).getString("Date"))){ - entryToday = true; - entryIndex = i; + if(journalArray != null){ + for(int i = 0; i < journalArray.length(); i++){ + if(sdf.format(today).equals(journalArray.getJSONObject(i).getString("Date"))){ + entryToday = true; + entryIndex = i; + } } } @@ -555,7 +631,6 @@ public class ProgressActivity extends AppCompatActivity { parent.addView(monthTextViewJournal, 0); try{ - Calendar cal = Calendar.getInstance(); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); @@ -565,25 +640,32 @@ public class ProgressActivity extends AppCompatActivity { int markColorIndex = 0; String oldExperiment = ""; - for(int i = 0; i < journalArray.length(); i++){ - if(i == 0) oldExperiment = journalArray.getJSONObject(i).getString("Experiment"); + if(journalArray != null){ + d("dbg_jourNNull", "true"); + for(int i = 0; i < journalArray.length(); i++){ + if(i == 0) oldExperiment = journalArray.getJSONObject(i).getString("Experiment"); - if(!journalArray.getJSONObject(i).getString("Experiment").equals(oldExperiment)){ - markColorIndex++; - oldExperiment = journalArray.getJSONObject(i).getString("Experiment"); - } + if(!journalArray.getJSONObject(i).getString("Experiment").equals(oldExperiment)){ + markColorIndex++; + oldExperiment = journalArray.getJSONObject(i).getString("Experiment"); + } - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(0,2))); - cal.set(Calendar.MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(3,5))-1); - cal.set(Calendar.YEAR, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(6,10))); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(0,2))); + cal.set(Calendar.MONTH, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(3,5))-1); + cal.set(Calendar.YEAR, Integer.parseInt(journalArray.getJSONObject(i).getString("Date").substring(6,10))); - if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) - && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) - && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ - calendarViewForJournal.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) + && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) + && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ + calendarViewForJournal.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + } + calendarViewForJournal.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis(), journalArray.getJSONObject(i).getString("Experiment"))); } - calendarViewForJournal.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis(), journalArray.getJSONObject(i).getString("Experiment"))); + } else { + d("dbg_jourNNull", "false"); + d("dbg_journal", journalArray.toString()); } + latestExperimentColor = Color.parseColor(markColor[markColorIndex%3]); } catch (JSONException e){ e.printStackTrace(); } @@ -671,39 +753,43 @@ public class ProgressActivity extends AppCompatActivity { int markColorIndex = 0; String oldExperiment = ""; - for(int i = 0; i < archivedExperimentData.length(); i++){ - if(i == 0) oldExperiment = archivedExperimentData.getJSONObject(i).getString("Experiment"); + if(archivedExperimentData != null){ + for(int i = 0; i < archivedExperimentData.length(); i++){ + if(i == 0) oldExperiment = archivedExperimentData.getJSONObject(i).getString("Experiment"); - if(!archivedExperimentData.getJSONObject(i).getString("Experiment").equals(oldExperiment)){ - markColorIndex++; - oldExperiment = archivedExperimentData.getJSONObject(i).getString("Experiment"); - } + if(!archivedExperimentData.getJSONObject(i).getString("Experiment").equals(oldExperiment)){ + markColorIndex++; + oldExperiment = archivedExperimentData.getJSONObject(i).getString("Experiment"); + } - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(0,2))); - cal.set(Calendar.MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(3,5))-1); - cal.set(Calendar.YEAR, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(6,10))); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(0,2))); + cal.set(Calendar.MONTH, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(3,5))-1); + cal.set(Calendar.YEAR, Integer.parseInt(archivedExperimentData.getJSONObject(i).getString("Date").substring(6,10))); - if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) - && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) - && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ - calendarViewForGraphs.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) + && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) + && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ + calendarViewForGraphs.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + } + calendarViewForGraphs.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis(), archivedExperimentData.getJSONObject(i).getString("Experiment"))); } - calendarViewForGraphs.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis(), archivedExperimentData.getJSONObject(i).getString("Experiment"))); - } - markColorIndex++; + markColorIndex++; + } - for(int i = 0; i < currentExperimentData.length(); i++){ - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(0,2))); - cal.set(Calendar.MONTH, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(3,5))-1); - cal.set(Calendar.YEAR, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(6,10))); + if(currentExperimentData != null){ + for(int i = 0; i < currentExperimentData.length(); i++){ + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(0,2))); + cal.set(Calendar.MONTH, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(3,5))-1); + cal.set(Calendar.YEAR, Integer.parseInt(currentExperimentData.getJSONObject(i).getString("Date").substring(6,10))); - if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) - && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) - && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ - calendarViewForGraphs.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + if(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == cal.get(Calendar.DAY_OF_MONTH) + && Calendar.getInstance().get(Calendar.MONTH) == cal.get(Calendar.MONTH) + && Calendar.getInstance().get(Calendar.YEAR) == cal.get(Calendar.YEAR)){ + calendarViewForGraphs.setCurrentDayBackgroundColor(Color.parseColor(markColor[markColorIndex%3])); + } + calendarViewForGraphs.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis())); } - calendarViewForGraphs.addEvent(new Event(Color.parseColor(markColor[markColorIndex%3]), cal.getTimeInMillis())); } calendarViewForGraphs.setListener(new CompactCalendarView.CompactCalendarViewListener() { @@ -835,27 +921,29 @@ public class ProgressActivity extends AppCompatActivity { long lowest = 0; try { - currentExperimentTitle.setText(Html.fromHtml("Current Experiment: " + localUserData.getJSONObject("lockedExperiment").getString("Title"))); - - DataPoint[] dataSeries; - - dataSeries = loopJSONArrayForPoints(currentExperimentData, new DataPoint[currentExperimentData.length()], 0); - lowest = loopJSONArrayForLowest(currentExperimentData, lowest); - - LineGraphSeries <DataPoint> series1 = new LineGraphSeries< >(dataSeries); - PointsGraphSeries <DataPoint> series2 = new PointsGraphSeries<>(dataSeries); - series2.setCustomShape(new PointsGraphSeries.CustomShape() { - @Override - public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) { - paint.setStrokeWidth(7); - canvas.drawLine(x-15, y-15, x+15, y+15, paint); - canvas.drawLine(x+15, y-15, x-15, y+15, paint); - } - }); + if (currentExperimentData != null) { + currentExperimentTitle.setText(Html.fromHtml("Current Experiment: " + localUserData.getJSONObject("lockedExperiment").getString("Title"))); + + DataPoint[] dataSeries; + + dataSeries = loopJSONArrayForPoints(currentExperimentData, new DataPoint[currentExperimentData.length()], 0); + lowest = loopJSONArrayForLowest(currentExperimentData, lowest); + + LineGraphSeries <DataPoint> series1 = new LineGraphSeries< >(dataSeries); + PointsGraphSeries <DataPoint> series2 = new PointsGraphSeries<>(dataSeries); + series2.setCustomShape(new PointsGraphSeries.CustomShape() { + @Override + public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) { + paint.setStrokeWidth(7); + canvas.drawLine(x-15, y-15, x+15, y+15, paint); + canvas.drawLine(x+15, y-15, x-15, y+15, paint); + } + }); - if(dataSeries.length == 0) selectedExperimentGraph.setTitle("No data! Answer a survey to display data!"); - selectedExperimentGraph.addSeries(series1); - selectedExperimentGraph.addSeries(series2); + if(dataSeries.length == 0) selectedExperimentGraph.setTitle("No data! Answer a survey to display data!"); + selectedExperimentGraph.addSeries(series1); + selectedExperimentGraph.addSeries(series2); + } } catch (JSONException e) { e.printStackTrace(); } @@ -883,6 +971,9 @@ public class ProgressActivity extends AppCompatActivity { DataPoint[] dataSeries; + d("dbg_archived", archivedExperimentData.toString()); + d("dbg_current", currentExperimentData.toString()); + dataSeries = loopJSONArrayForPoints(archivedExperimentData, new DataPoint[currentExperimentData.length() + archivedExperimentData.length()], 0); lowest = loopJSONArrayForLowest(archivedExperimentData, lowest); @@ -892,13 +983,10 @@ public class ProgressActivity extends AppCompatActivity { LineGraphSeries <DataPoint> series1 = new LineGraphSeries< >(dataSeries); PointsGraphSeries <DataPoint> series2 = new PointsGraphSeries<>(dataSeries); - series2.setCustomShape(new PointsGraphSeries.CustomShape() { - @Override - public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) { - paint.setStrokeWidth(7); - canvas.drawLine(x-15, y-15, x+15, y+15, paint); - canvas.drawLine(x+15, y-15, x-15, y+15, paint); - } + series2.setCustomShape((canvas, paint, x, y, dataPoint) -> { + paint.setStrokeWidth(7); + canvas.drawLine(x-15, y-15, x+15, y+15, paint); + canvas.drawLine(x+15, y-15, x-15, y+15, paint); }); overallGraph.addSeries(series1); overallGraph.addSeries(series2); diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ProjectMacros.java b/app/src/main/java/com/yearthreeproject/xbframework/ProjectMacros.java index 6445d2653fa27c2117ea83c5e4019a0db189d195..0e0e206affb3a4bc84623746997afe2ccd049764 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ProjectMacros.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ProjectMacros.java @@ -1,5 +1,6 @@ package com.yearthreeproject.xbframework; +import android.annotation.SuppressLint; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationChannel; @@ -17,13 +18,13 @@ import android.widget.Toast; import androidx.annotation.RequiresApi; import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.Random; @@ -91,17 +92,14 @@ class ProjectMacros { sb.append(line).append("\n"); } return sb.toString(); - } catch (FileNotFoundException e) { - return ""; - } catch (UnsupportedEncodingException e) { - return ""; } catch (IOException e) { return ""; } } + @SuppressLint("ShortAlarm") @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; for(int i = 0; i < contextTitle.length(); i++){ randSeed += contextTitle.charAt(i); @@ -111,11 +109,11 @@ class ProjectMacros { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE); assert notificationManager != null; - if (notificationManager.getNotificationChannel(channelId) == null) { + if (notificationManager.getNotificationChannel("ALL_CHANNEL") == null) { CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1; String description = "Channel started for " + contextTitle; int importance = NotificationManager.IMPORTANCE_DEFAULT; - NotificationChannel channel = new NotificationChannel(channelId, name, importance); + NotificationChannel channel = new NotificationChannel("ALL_CHANNEL", name, importance); channel.setDescription(description); notificationManager.createNotificationChannel(channel); } @@ -124,10 +122,10 @@ class ProjectMacros { Notification.Builder builder = new Notification.Builder(currentClassDotThis); builder.setContentTitle(contextTitle); builder.setContentText(contextText); - builder.setSmallIcon(resourceId); + builder.setSmallIcon(R.raw.box_outline); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - builder.setChannelId(channelId); + builder.setChannelId("ALL_CHANNEL"); } Notification notification = new Notification.BigTextStyle(builder) @@ -146,12 +144,12 @@ class ProjectMacros { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("kkmmsshh"); String repTimeString = simpleDateFormat.format(repeatTime.getTime()); - d("dbg_stringformat", repTimeString); + d("dbg_time", repTimeString); long millisRepeatTime = 0; 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 { } @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; for(int i = 0; i < contextTitle.length(); i++){ randSeed += contextTitle.charAt(i); @@ -180,11 +178,11 @@ class ProjectMacros { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) currentClassDotThis.getSystemService(Context.NOTIFICATION_SERVICE); assert notificationManager != null; - if (notificationManager.getNotificationChannel(channelId) == null) { + if (notificationManager.getNotificationChannel("ALL_CHANNEL") == null) { CharSequence name = "Channel "+notificationManager.getNotificationChannels().size()+1; String description = "Channel started for " + contextTitle; int importance = NotificationManager.IMPORTANCE_DEFAULT; - NotificationChannel channel = new NotificationChannel(channelId, name, importance); + NotificationChannel channel = new NotificationChannel("ALL_CHANNEL", name, importance); channel.setDescription(description); notificationManager.createNotificationChannel(channel); } @@ -193,10 +191,10 @@ class ProjectMacros { Notification.Builder builder = new Notification.Builder(currentClassDotThis); builder.setContentTitle(contextTitle); builder.setContentText(contextText); - builder.setSmallIcon(resourceId); + builder.setSmallIcon(R.raw.box_outline); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - builder.setChannelId(channelId); + builder.setChannelId("ALL_CHANNEL"); } Notification notification = new Notification.BigTextStyle(builder) @@ -211,6 +209,7 @@ class ProjectMacros { PendingIntent pendingIntent = PendingIntent.getBroadcast(currentClassDotThis, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) currentClassDotThis.getSystemService(Context.ALARM_SERVICE); + assert alarmManager != null; alarmManager.cancel(pendingIntent); } @@ -272,4 +271,23 @@ class ProjectMacros { } 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; + } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/SurveyResponseActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/SurveyResponseActivity.java index 7d16d895f955e3f6220415479e07d8ff2c9cbf0b..59c8b85d500a00f76961f26631ec5e3628c06a57 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/SurveyResponseActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/SurveyResponseActivity.java @@ -18,12 +18,24 @@ import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; 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.JSONException; import org.json.JSONObject; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Objects; import static android.util.Log.d; @@ -78,20 +90,17 @@ public class SurveyResponseActivity extends AppCompatActivity { } for (int i = 0; i < questions.length(); i++) { - surveyScrollView.addView(createNewQuestions(questions.get(i).toString(), i)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + surveyScrollView.addView(createNewQuestions(questions.get(i).toString(), i)); + } } } catch (JSONException e) { e.printStackTrace(); } - //FloatingActionButton fab = findViewById; - /*fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - completeSubmission(); - } - });*/ + FloatingActionButton fab = findViewById(R.id.surveyExperimentFAB); + fab.setOnClickListener(v -> completeSubmission()); } private void completeSubmission() { @@ -102,14 +111,78 @@ public class SurveyResponseActivity extends AppCompatActivity { } if (correctSubmission) { - // TODO: handle the submission by inputting responses into some sort of JSON to be retained, for now do nothing - d("dbg_submit", responses.toString()); + JSONArray rawResponses = new JSONArray(); + 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(); } else { 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) { RelativeLayout relLayout = new RelativeLayout(this); @@ -159,16 +232,13 @@ public class SurveyResponseActivity extends AppCompatActivity { relLayout.addView(questionText, questionTextAlignment); for (int i = 0; i < buttonArray.size(); i++) { - buttonArray.get(i).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - for (int x = 0; x < buttonArray.size(); x++) { - if (x + 1 != v.getId()) { - buttonArray.get(x).setChecked(false); - } else { - buttonArray.get(x).setChecked(true); - responses.set(index, x + 1); - } + buttonArray.get(i).setOnClickListener(v -> { + for (int x = 0; x < buttonArray.size(); x++) { + if (x + 1 != v.getId()) { + buttonArray.get(x).setChecked(false); + } else { + buttonArray.get(x).setChecked(true); + responses.set(index, x + 1); } } }); diff --git a/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java index 7428fa28c179c7571d82735d47b352eb7ffb052c..016f70eb48b37fc5111614815cdcd7b65ae025bc 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/TestingActivity.java @@ -102,7 +102,7 @@ public class TestingActivity extends AppCompatActivity { secondTestButton.setOnClickListener(new View.OnClickListener() { @Override 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 { 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); } }); diff --git a/app/src/main/res/layout/content_boxes.xml b/app/src/main/res/layout/content_boxes.xml index 756a5d95ab007b36eca01c19b4bb3905318bd38b..1ec6700c3fa499e281422220af05a81043382be5 100644 --- a/app/src/main/res/layout/content_boxes.xml +++ b/app/src/main/res/layout/content_boxes.xml @@ -21,7 +21,19 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:weightSum="1" /> + android:weightSum="1" > + + </LinearLayout> </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> diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 6ee5ef90e50b082fe16fbd64e1ff1a18dadaa05b..cd19826a1ac4b77df3bf806341bfcf478824adde 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -12,56 +12,38 @@ tools:context=".MainActivity" 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 android:id="@+id/HomeSurveyButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:backgroundTint="@color/calendarBackground" + android:backgroundTint="@color/colorPrimaryAccent" android:textColor="@color/colorPrimary" android:layout_weight="1" android:text="@string/HomeSurvey" /> <Button - android:id="@+id/HomeShopButton" + android:id="@+id/HomeExperimentsButton" 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_shop" /> + android:backgroundTint="@color/colorPrimaryAccent" + android:text="@string/main_experiments" + android:textColor="@color/colorPrimary" /> <Button - android:id="@+id/HomeExperimentsButton" + android:id="@+id/HomeShopButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:backgroundTint="@color/calendarBackground" + android:backgroundTint="@color/colorPrimaryAccent" android:textColor="@color/colorPrimary" android:layout_weight="1" - android:text="@string/main_experiments" /> + android:text="@string/main_shop" /> <Button android:id="@+id/HomeProgressButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:backgroundTint="@color/calendarBackground" + android:backgroundTint="@color/colorPrimaryAccent" android:textColor="@color/colorPrimary" android:layout_weight="1" android:text="@string/main_progress" /> @@ -70,7 +52,7 @@ android:id="@+id/HomeAboutButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:backgroundTint="@color/calendarBackground" + android:backgroundTint="@color/colorPrimaryAccent" android:textColor="@color/colorPrimary" android:layout_weight="1" android:text="@string/main_about" /> diff --git a/app/src/main/res/layout/content_new_box.xml b/app/src/main/res/layout/content_new_box.xml index e3179adecd3506562199c45632439174e44f6d1b..91b9c2adfc13f8a5fb0317ce2c251591579f008b 100644 --- a/app/src/main/res/layout/content_new_box.xml +++ b/app/src/main/res/layout/content_new_box.xml @@ -173,18 +173,13 @@ </LinearLayout> </ScrollView> - <LinearLayout + <com.google.android.material.floatingactionbutton.FloatingActionButton + android:id="@+id/NewBoxSubmitFAB" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_gravity="bottom|end" android:layout_weight="0" - android:orientation="horizontal"> - - <Button - android:id="@+id/NewBoxSubmitButton" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - style="?android:attr/buttonBarButtonStyle" - android:text="@string/NewBoxSubmitButton" /> - </LinearLayout> + app:backgroundTint="@color/colorPrimary" + app:fabSize="normal" + app:srcCompat="@drawable/ic_action_right" /> </LinearLayout> diff --git a/app/src/main/res/layout/content_progress.xml b/app/src/main/res/layout/content_progress.xml index ca4e616a75ccb46200f1d8ffa1ac8a6caacef559..11078905811259c99f3aa2070ec52569011c656b 100644 --- a/app/src/main/res/layout/content_progress.xml +++ b/app/src/main/res/layout/content_progress.xml @@ -54,7 +54,7 @@ android:layout_height="250dp" android:paddingLeft="10dp" android:paddingRight="10dp" - app:compactCalendarBackgroundColor="@color/calendarBackground" + app:compactCalendarBackgroundColor="@color/colorPrimaryAccent" app:compactCalendarCurrentDayBackgroundColor="#8F587B7F" app:compactCalendarCurrentSelectedDayBackgroundColor="@color/colorPrimary" app:compactCalendarMultiEventIndicatorColor="@color/colorAccent" @@ -75,7 +75,7 @@ android:layout_height="250dp" android:paddingLeft="10dp" android:paddingRight="10dp" - app:compactCalendarBackgroundColor="@color/calendarBackground" + app:compactCalendarBackgroundColor="@color/colorPrimaryAccent" app:compactCalendarCurrentDayBackgroundColor="#8F587B7F" app:compactCalendarCurrentSelectedDayBackgroundColor="@color/colorPrimary" app:compactCalendarMultiEventIndicatorColor="@color/colorAccent" diff --git a/app/src/main/res/raw/local_user_data.json b/app/src/main/res/raw/local_user_data.json index 67dbdec850df813c3df871a1270a8c4d7a994679..46941a991d96ca9c0f435384ead84acfd7a51ba5 100644 --- a/app/src/main/res/raw/local_user_data.json +++ b/app/src/main/res/raw/local_user_data.json @@ -1,7 +1,6 @@ { "dateUntil":"22\/03\/2020", - "savedUserID":"A01", - "locked":true, + "locked":false, "lockedExperiment":{ "Title":"Sunlight", "Instructions":"Get 30 to 45 minutes of sunlight a day. Make sure your room captures sunlight.", diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 80576ca1fe8c5612003f49ed33ec3448a33d0b0c..d8fe2f4a6ae7473c7869aa3de76a8d3c76a3f887 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,12 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="meecs" > - <item>Select a MEECS…</item> <item>Move</item> <item>Eat</item> <item>Engage</item> <item>Cogitate</item> <item>Sleep</item> - + <item>Select a MEECS…</item> </string-array> </resources> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 97af75ef764490e35c51777c83baa4e416a4c7e0..7cac90f7cd635fd2f7c49219f33facf50b139461 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,6 @@ <resources> <color name="colorPrimary">#587B7F</color> <color name="colorPrimaryDark">#212426</color> - <color name="calendarBackground">#CED9D9</color> + <color name="colorPrimaryAccent">#CED9D9</color> <color name="colorAccent">#FAFAFA</color> </resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 05cec78fa7e486ca7f201a9830e1311907f035d4..34f34dc0409f8834c15d4074ef67feb31f271a11 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,4 +58,7 @@ <string name="com_auth0_domain">eamonn-backend-oauth.eu.auth0.com</string> <string name="auth0_scheme">https</string> + <string name="mongo_admin_password">adminPassword</string> + <string name="mongo_stitch_id">xbframeworkstitch-sgpse</string> + </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bfbc53a203d4fb2ddfbaa295aae8d9b133bc1fb4..c22d7367875dda6aee03e473083b45b942a9e423 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -9,6 +9,18 @@ <item name="colorAccent">@color/colorAccent</item> <item name="android:navigationBarColor" tools:targetApi="lollipop">@color/colorAccent</item> <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item> + <item name="colorButtonNormal">@color/colorPrimaryAccent</item> + <item name="android:textColor">@color/colorPrimary</item> + <item name="android:editTextColor">@color/colorPrimary</item> + <item name="android:textColorHint">@color/colorPrimaryAccent</item> + <item name="colorControlNormal">@color/colorPrimary</item> + <item name="colorControlActivated">@color/colorPrimary</item> + <item name="colorControlHighlight">@color/colorPrimary</item> + <item name="colorSwitchThumbNormal">@color/colorPrimary</item> + </style> + + <style name="PrimaryColoredButton" parent="Base.Widget.AppCompat.Button.Colored"> + </style> <style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog"> diff --git a/build.gradle b/build.gradle index 670309ceb972615a5fb6f2b997bd766ea9e216e9..ff1b8a87321d82e5fe76add2c14c5c71d5660697 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.1' + classpath 'com.android.tools.build:gradle:3.6.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files