diff --git a/app/build.gradle b/app/build.gradle index fda8b1b924098c93117f82db1c075e2dcc83cbd0..5e6f69070edb1221837b4b5b1690672830315a90 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,10 +21,12 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'com.android.support:cardview-v7:28.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.google.android.material:material:1.0.0' + api 'com.theartofdev.edmodo:android-image-cropper:2.8.+' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4c5844807678e9dfb78e65fc7e6a2d8d1c7b0db7..2bfacbef5ba81cd29afbf6bebf33eda12050299d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,9 +3,12 @@ xmlns:tools="http://schemas.android.com/tools" package="com.yearthreeproject.xbframework"> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <application android:allowBackup="true" - android:icon="@mipmap/ic_launcher" + android:icon="@raw/logo" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" @@ -37,7 +40,7 @@ android:theme="@style/AppTheme.NoActionBar"/> <activity - android:name=".ExperimentsListActivity" + android:name=".ExperimentActivity" android:label="Experiment" android:theme="@style/AppTheme.NoActionBar"/> @@ -51,6 +54,19 @@ android:label="Progress" android:theme="@style/AppTheme.NoActionBar"/> + <activity + android:name=".NewBox" + android:label="NewBox" + android:theme="@style/AppTheme.NoActionBar"/> + + <activity + android:name=".ExperimentSurveyCreatorActivity" + android:label="ExperimentSurveyCreator" + android:theme="@style/AppTheme.NoActionBar"/> + + <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" + android:theme="@style/Base.Theme.AppCompat"/> + </application> </manifest> \ No newline at end of file diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000000000000000000000000000000000000..5bdb4f1f102ffc563c692571555611512071140d Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java index ccc566535cf41cb14e5ee8ed37d1f5961ebf38d7..74eae45171d820dd113b27c6daa855698fa5a0e2 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/AboutActivity.java @@ -10,19 +10,22 @@ import androidx.appcompat.widget.Toolbar; public class AboutActivity extends AppCompatActivity { - private Button homeButton; - private Toolbar myToolbar; + private Button backHomeButton; + private Toolbar toolbar; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); - myToolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); - homeButton=(Button) findViewById(R.id.backHomeAbout); - homeButton.setOnClickListener(new View.OnClickListener(){ + backHomeButton = (Button) findViewById(R.id.AboutBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java index b8e282b28047a14624fc27afe66add18be12381d..a352b73b470d7cf1a21ca822561c08e35ec4cdc7 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/BoxesActivity.java @@ -1,6 +1,5 @@ package com.yearthreeproject.xbframework; -import android.app.ActionBar; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; @@ -26,22 +25,18 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import static android.util.Log.d; - public class BoxesActivity extends AppCompatActivity { - private Toolbar myToolbar; - private Button backHome; + private Toolbar toolbar; + private Button backHomeButton; @Override - public boolean onCreateOptionsMenu(Menu menu){ - MenuItem item = menu.add("Testing"); - item.setTitle("Testing!"); - item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + public boolean onCreateOptionsMenu(Menu menu) { + MenuItem createBox = menu.add("Create New Box!"); + createBox.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - // do stuff - d("Menu", (String) item.getTitle()); + startActivity(new Intent(BoxesActivity.this, NewBox.class)); return false; } }); @@ -50,22 +45,25 @@ public class BoxesActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - // Ordinary setup of UI for general app purposes + // Ordinary setup of UI for general app purposes super.onCreate(savedInstanceState); setContentView(R.layout.activity_boxes); - myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); - LinearLayout grid = findViewById(R.id.experimentsGrid); - + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + LinearLayout inFiveLayout = findViewById(R.id.BoxesInFiveLayout); - // JSON loading from local directory, could be implemented to stream from online + // JSON loading from local directory, could be implemented to stream from online InputStream inputStream = getResources().openRawResource(R.raw.box); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - final JSONArray MEECS; + JSONArray boxes = new JSONArray(); + final String[] inFive = {"Move", "Eat", "Engage", "Cogitate", "Sleep"}; int ctr; - // Try, in order to avoid errors in compilation and catastrophic errors + // Try, in order to avoid errors in compilation and catastrophic errors try { ctr = inputStream.read(); @@ -75,80 +73,84 @@ public class BoxesActivity extends AppCompatActivity { } inputStream.close(); - // Full loading of json array with each data item included - MEECS = new JSONArray(byteArrayOutputStream.toString()); + boxes = new JSONArray(byteArrayOutputStream.toString()); + + LinearLayout[] inFiveLayoutArray = new LinearLayout[5]; - LinearLayout[] meecsHolder = new LinearLayout[5]; + LinearLayout[] inFiveAvailableBoxes = new LinearLayout[boxes.length()]; - LinearLayout[] layoutHolder = new LinearLayout[MEECS.length()]; + for (int i = 0; i < inFive.length; i++) { + inFiveLayoutArray[i] = new LinearLayout(this); - for(int i = 0; i < MEECS.length(); i++){ - final JSONArray boxes = MEECS.getJSONObject(i).getJSONArray("Box"); - meecsHolder[i] = new LinearLayout(this); - TextView groupTitle = new TextView(this); + TextView inFiveTitle = new TextView(this); - groupTitle.setText(MEECS.getJSONObject(i).getString("Group")); - groupTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36); - groupTitle.setPadding(0,8,0,0); + inFiveTitle.setText(inFive[i]); + inFiveTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36); + inFiveTitle.setPadding(0, 8, 0, 0); - meecsHolder[i].setOrientation(LinearLayout.VERTICAL); - meecsHolder[i].addView(groupTitle); + inFiveLayoutArray[i].setOrientation(LinearLayout.VERTICAL); + inFiveLayoutArray[i].addView(inFiveTitle); View hr = new View(this); - ViewGroup.LayoutParams tempLayout = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); - hr.setLayoutParams(tempLayout); + ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); + hr.setLayoutParams(hrLayoutParams); hr.setBackgroundColor(Color.parseColor("#888888")); - meecsHolder[i].addView(hr); + inFiveLayoutArray[i].addView(hr); - for(int j = 0; j < boxes.length(); j++){ - layoutHolder[j] = new LinearLayout(this); - layoutHolder[j].setOrientation(LinearLayout.HORIZONTAL); - layoutHolder[j].setPadding(0, 8, 0, 8); + for (int j = 0; j < boxes.length(); j++) { + final JSONObject box = boxes.getJSONObject(j); - LinearLayout textBox = new LinearLayout(this); - textBox.setOrientation(LinearLayout.VERTICAL); - textBox.setPadding(16, 0, 0, 0); + if(box.getString("Group").matches(inFive[i])){ + inFiveAvailableBoxes[j] = new LinearLayout(this); + inFiveAvailableBoxes[j].setOrientation(LinearLayout.HORIZONTAL); + inFiveAvailableBoxes[j].setPadding(0, 8, 0, 8); - TextView titleOfItem = new TextView(this); - titleOfItem.setText(boxes.getJSONObject(j).getString("Name")); - titleOfItem.setTextSize(TypedValue.COMPLEX_UNIT_SP,28); + LinearLayout boxLayout = new LinearLayout(this); + boxLayout.setOrientation(LinearLayout.VERTICAL); + boxLayout.setPadding(16, 0, 0, 0); - TextView descOfItem = new TextView(this); + TextView titleOfBox = new TextView(this); + titleOfBox.setText(box.getString("Name")); + titleOfBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28); - descOfItem.setText(boxes.getJSONObject(j).getString("Locked")); - textBox.addView(titleOfItem); - textBox.addView(descOfItem); + TextView descriptionOfBox = new TextView(this); - ImageView iV; - if(!boxes.getJSONObject(j).getString("Image").equals("null")) { - iV = new ImageView(this); - iV.setImageResource(R.mipmap.ic_launcher); - layoutHolder[j].addView(iV); - } + descriptionOfBox.setText(box.getString("Blurb")); + + boxLayout.addView(titleOfBox); + boxLayout.addView(descriptionOfBox); - layoutHolder[j].addView(textBox); - - layoutHolder[j].setId(j); - layoutHolder[j].setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - try{ - boolean locked = boxes.getJSONObject(v.getId()).getBoolean("Locked"); - if(!locked) { - Intent openPage = new Intent(BoxesActivity.this, ExperimentsListActivity.class); - openPage.putExtra("JSON", boxes.getJSONObject(v.getId()).toString()); - startActivity(openPage); - finish(); + ImageView boxLogo; + if (!box.getString("Image").equals("null")) { + boxLogo = new ImageView(this); + boxLogo.setImageResource(R.mipmap.ic_launcher); + inFiveAvailableBoxes[j].addView(boxLogo); + } + + inFiveAvailableBoxes[j].addView(boxLayout); + + inFiveAvailableBoxes[j].setId(j); + inFiveAvailableBoxes[j].setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + boolean locked = box.getBoolean("Locked"); + if (!locked) { + Intent openPage = new Intent(BoxesActivity.this, ExperimentActivity.class); + openPage.putExtra("JSON", box.toString()); + startActivity(openPage); + finish(); + } + } catch (JSONException e) { + e.printStackTrace(); } - } catch (JSONException e){ - e.printStackTrace(); } - } - }); - meecsHolder[i].addView(layoutHolder[j]); + }); + inFiveLayoutArray[i].addView(inFiveAvailableBoxes[j]); + } } - grid.addView(meecsHolder[i]); + inFiveLayout.addView(inFiveLayoutArray[i]); } } catch (JSONException e) { e.printStackTrace(); @@ -156,14 +158,13 @@ public class BoxesActivity extends AppCompatActivity { e.printStackTrace(); } - backHome=findViewById(R.id.experimentsBackHome); - backHome.setOnClickListener(new View.OnClickListener(){ + backHomeButton = findViewById(R.id.BoxesBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } }); - } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..c37aa73bc6a7474d843863b713190c160191bec7 --- /dev/null +++ b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentActivity.java @@ -0,0 +1,133 @@ +package com.yearthreeproject.xbframework; + +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; + +import static android.util.Log.d; + +public class ExperimentActivity extends AppCompatActivity { + + private Toolbar toolbar; + private Button backHomeButton; + private Button submitButton; + private ArrayList<RadioButton> experimentsRadioButtonArray; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_experiment); + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + LinearLayout experimentInfoLayout = findViewById(R.id.ExperimentInfoLayout); + + try { + JSONObject boxJSON = new JSONObject(getIntent().getStringExtra("JSON")); + setTitle(boxJSON.getString("Name")); // Sets the title of the page (in the toolbar) + + /* Description | TextView + * Warning | TextView (Red) + * Experiment Group Name | TextView + * Hr + * Button choice between experiments in group + * Repeat from experiment group name + */ + + TextView boxDescription = new TextView(this); + TextView boxWarning = new TextView(this); + + boxDescription.setText(boxJSON.getString("Description")); + boxWarning.setText(boxJSON.getString("WarningText")); + boxWarning.setTextColor(Color.parseColor("#f00808")); + + experimentInfoLayout.addView(boxDescription); + experimentInfoLayout.addView(boxWarning); + + + JSONArray experimentsJSONArray = boxJSON.getJSONArray("Experiments"); + + experimentsRadioButtonArray = new ArrayList<RadioButton>(); + + int radioButtonUniqueId = 0; + + for (int i = 0; i < experimentsJSONArray.length(); i++) { + + View hr = new View(this); + ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); + hr.setLayoutParams(hrLayoutParams); + hr.setBackgroundColor(Color.parseColor("#888888")); + hr.setPadding(0, 0, 0, 16); + + TextView experimentGroupName = new TextView(this); + experimentGroupName.setText(experimentsJSONArray.getJSONObject(i).getString("Group")); + experimentGroupName.setPadding(0, 8, 0, 8); + + experimentInfoLayout.addView(hr); + experimentInfoLayout.addView(experimentGroupName); + + JSONArray experimentChoices = experimentsJSONArray.getJSONObject(i).getJSONArray("Options"); + + for (int j = 0; j < experimentChoices.length(); j++) { + RadioButton experimentRadioButton = new RadioButton(this); + JSONObject experimentData = experimentChoices.getJSONObject(j); + + experimentRadioButton.setId(radioButtonUniqueId); + + experimentRadioButton.setText(experimentData.getString("Title")); + 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); + } + } + }); + + experimentsRadioButtonArray.add(experimentRadioButton); + experimentInfoLayout.addView(experimentRadioButton); + + radioButtonUniqueId++; + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + + submitButton = findViewById(R.id.ExperimentSubmitButton); + submitButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + for(int x = 0; x < experimentsRadioButtonArray.size(); x++) + if(experimentsRadioButtonArray.get(x).isChecked()){ + d("submit", experimentsRadioButtonArray.get(x).getText().toString()); + } + } + }); + + backHomeButton = findViewById(R.id.ExperimentBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + finish(); + } + }); + } +} diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..c0970d01e271b37ff96e3c4ab7e293573ad06cec --- /dev/null +++ b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentSurveyCreatorActivity.java @@ -0,0 +1,193 @@ +package com.yearthreeproject.xbframework; + +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.FileNotFoundException; +import java.io.InputStream; + +import static android.util.Log.d; + +public class ExperimentSurveyCreatorActivity extends AppCompatActivity { + + private Toolbar toolbar; + private Button submitButton, backHomeButton; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_experiment_survey_creator); + + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + try{ + final JSONObject boxInfo = new JSONObject(getIntent().getStringExtra("JSON")); + + + d("sub, gI", String.valueOf(getIntent().getIntExtra("GroupIndex", 0))); + d("sub, eI", String.valueOf(getIntent().getIntExtra("ExperimentIndex", 0))); + + JSONObject groupJSON = boxInfo.getJSONArray("Experiments").getJSONObject(getIntent().getIntExtra("GroupIndex", 0)); + JSONArray experimentJSON = groupJSON.getJSONArray("Options"); + + d("sub, grpLen", String.valueOf(boxInfo.getJSONArray("Experiments").length())); + d("sub, exLen", String.valueOf(experimentJSON.length())); + + d("sub, grpJSON", boxInfo.getJSONArray("Experiments").toString()); + d("sub, exJSON", boxInfo.getJSONArray("Experiments").getJSONObject(getIntent().getIntExtra("GroupIndex",0)).getJSONArray("Options").getJSONObject(getIntent().getIntExtra("ExperimentIndex", 0)).toString()); + + + submitButton = findViewById(R.id.ExperimentSurveyCreatorSubmitButton); + submitButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + try{ + Intent openPage = new Intent(ExperimentSurveyCreatorActivity.this, ExperimentSurveyCreatorActivity.class); + //d("sub", boxInfo.getJSONArray("Experiments").toString()); + openPage.putExtra("JSON", getIntent().getStringExtra("JSON")); + + JSONObject groupJSON = boxInfo.getJSONArray("Experiments").getJSONObject(getIntent().getIntExtra("GroupIndex", 0)); + JSONArray experimentJSON = groupJSON.getJSONArray("Options"); + + + if(getIntent().getIntExtra("ExperimentIndex", 0)+1 >= experimentJSON.length()){ + openPage.putExtra("ExperimentIndex", 0); + if(getIntent().getIntExtra("GroupIndex", 0)+1 >= boxInfo.getJSONArray("Experiments").length()){ + d("sub", "end of json check 1"); + + // do the thing with saving into the current JSON, then return to the box page and show the new file (close every previous page if possible and launch new activity) + Intent intent = new Intent(getApplicationContext(), BoxesActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + + } else{ + d("sub", "end of group"); + openPage.putExtra("GroupIndex", getIntent().getIntExtra("GroupIndex", 0)+1); + startActivity(openPage); + } + } else if (getIntent().getIntExtra("GroupIndex", 0)+1 >= boxInfo.getJSONArray("Experiments").length()) { + // Should never enter this check, but edge case just incase of bug, so run function just the same + d("sub", "end of json check 2"); + openPage.putExtra("ExperimentIndex", getIntent().getIntExtra("ExperimentIndex", 0)); + openPage.putExtra("GroupIndex", getIntent().getIntExtra("GroupIndex", 0)); + startActivity(openPage); + } else { + d("sub", "remain in the same group"); + openPage.putExtra("ExperimentIndex", getIntent().getIntExtra("ExperimentIndex", 0) + 1); + openPage.putExtra("GroupIndex", getIntent().getIntExtra("GroupIndex", 0)); + startActivity(openPage); + } + } catch(JSONException e){ + e.printStackTrace(); + } + } + }); + + if(!boxInfo.getString("Image").isEmpty()){ + Drawable yourDrawable; + InputStream inputStream = getContentResolver().openInputStream(Uri.parse(boxInfo.getString("Image"))); + yourDrawable = Drawable.createFromStream(inputStream, boxInfo.getString("Image")); + getSupportActionBar().setLogo(yourDrawable); + } else{ + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + } + setTitle(boxInfo.getString("Name")); + + LinearLayout scrollLayout = findViewById(R.id.SurveyCreationLayout); + + TextView boxDescription = new TextView(this); + TextView boxWarning = new TextView(this); + + boxDescription.setText(boxInfo.getString("Description")); + boxWarning.setText(boxInfo.getString("WarningText")); + boxWarning.setTextColor(Color.parseColor("#f00808")); + + scrollLayout.addView(boxDescription); + scrollLayout.addView(boxWarning); + + JSONObject experimentObject = boxInfo.getJSONArray("Experiments").getJSONObject(getIntent().getIntExtra("GroupIndex", 0)); + + View hr = new View(ExperimentSurveyCreatorActivity.this); + ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); + hr.setLayoutParams(hrLayoutParams); + hr.setBackgroundColor(Color.parseColor("#888888")); + + scrollLayout.addView(hr); + + TextView groupTitle = new TextView(this); + groupTitle.setText(experimentObject.getString("Group")); + + scrollLayout.addView(groupTitle); + + JSONObject experiment = experimentObject.getJSONArray("Options").getJSONObject(getIntent().getIntExtra("ExperimentIndex", 0)); + + TextView experimentTitle = new TextView(this); + experimentTitle.setText(experiment.getString("Title")); + + TextView experimentDesc = new TextView(this); + experimentDesc.setText(experiment.getString("Description")); + + scrollLayout.addView(experimentTitle); + scrollLayout.addView(experimentDesc); + + View hr2 = new View(ExperimentSurveyCreatorActivity.this); + hr2.setLayoutParams(hrLayoutParams); + hr2.setBackgroundColor(Color.parseColor("#888888")); + + scrollLayout.addView(hr2); + + TextView surveyTitle = new TextView(this); + surveyTitle.setText("Survey"); + scrollLayout.addView(surveyTitle); + + LinearLayout surveyCreationHorizontalLinearLayout = new LinearLayout(this); + surveyCreationHorizontalLinearLayout.setOrientation(LinearLayout.HORIZONTAL); + + LinearLayout surveyCreationLabelLayout = new LinearLayout(this); + surveyCreationLabelLayout.setOrientation(LinearLayout.VERTICAL); + + TextView questionNumberLabel = new TextView(this); + int questionIndex = 1; + String questionLabel = "Question " + questionIndex + ":"; + questionNumberLabel.setText(questionLabel); + + surveyCreationLabelLayout.addView(questionNumberLabel); + surveyCreationHorizontalLinearLayout.addView(surveyCreationLabelLayout); + scrollLayout.addView(surveyCreationHorizontalLinearLayout); + + + + } catch (JSONException e){ + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + backHomeButton = findViewById(R.id.ExperimentSurveyCreatorBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + finish(); + } + }); + + } +} diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentsListActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ExperimentsListActivity.java deleted file mode 100644 index f7aefedcc8d5f4264c29d6ee984d0d24ac7cfac0..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/yearthreeproject/xbframework/ExperimentsListActivity.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.yearthreeproject.xbframework; - -import android.graphics.Color; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.RadioButton; -import android.widget.RadioGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.w3c.dom.Text; - -import java.util.ArrayList; -import java.util.Objects; - -import static android.util.Log.d; - -public class ExperimentsListActivity extends AppCompatActivity { - - private Toolbar myToolbar; - private Button backHome; - private Button submit; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_experiments_list); - myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); - d("Launched", "Experiments"); - - LinearLayout linLayout = findViewById(R.id.experimentLayout); - - try { - JSONObject jsonObj = new JSONObject(getIntent().getStringExtra("JSON")); - setTitle(jsonObj.getString("Name")); - - /* Description | TextView - * Warning | TextView (Red) - * Experiment Group Name | TextView - * Hr - * Button choice between experiments in group - * Repeat from experiment group name - */ - - TextView description = new TextView(this); - TextView warning = new TextView(this); - - description.setText(jsonObj.getString("Description")); - warning.setText(jsonObj.getString("WarningText")); - warning.setTextColor(Color.parseColor("#f00808")); - - linLayout.addView(description); - linLayout.addView(warning); - - - - JSONArray experimentsList = jsonObj.getJSONArray("Experiments"); - - final ArrayList<RadioButton> rbArray = new ArrayList<RadioButton>(); - - int uniqueId = 0; - for( int i = 0; i < experimentsList.length(); i++){ - - View hr = new View(this); - ViewGroup.LayoutParams tempLayout = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); - hr.setLayoutParams(tempLayout); - hr.setBackgroundColor(Color.parseColor("#888888")); - hr.setPadding(0,0,0,16); - - TextView experimentGroupName = new TextView(this); - experimentGroupName.setText(experimentsList.getJSONObject(i).getString("Group")); - experimentGroupName.setPadding(0,8,0,8); - - linLayout.addView(hr); - linLayout.addView(experimentGroupName); - - JSONArray experimentOptions = experimentsList.getJSONObject(i).getJSONArray("Options"); - - for( int j = 0; j < experimentOptions.length(); j++){ - - RadioButton rB = new RadioButton(this); - rB.setId(uniqueId); - rB.setText(experimentOptions.getString(j)); - rB.setOnClickListener(new View.OnClickListener(){ - public void onClick(View v) { - for(int x = 0; x < rbArray.size(); x++){ - if(x != v.getId()) rbArray.get(x).setChecked(false); - else rbArray.get(x).setChecked(true); - } - } - }); - uniqueId += 1; - rbArray.add(rB); - - linLayout.addView(rB); - } - } - } catch (JSONException e) { - e.printStackTrace(); - } - - submit = findViewById(R.id.experimentSubmit); - submit.setOnClickListener(new View.OnClickListener(){ - public void onClick(View v){ - d("Button", "Submit!"); - } - }); - - backHome=findViewById(R.id.experimentsBackHome); - backHome.setOnClickListener(new View.OnClickListener(){ - public void onClick(View v) { - finish(); - } - }); - } -} diff --git a/app/src/main/java/com/yearthreeproject/xbframework/FileStoreReader.java b/app/src/main/java/com/yearthreeproject/xbframework/FileStoreReader.java new file mode 100644 index 0000000000000000000000000000000000000000..d259f7a627df202b203525566652523d1990c2a6 --- /dev/null +++ b/app/src/main/java/com/yearthreeproject/xbframework/FileStoreReader.java @@ -0,0 +1,67 @@ +package com.yearthreeproject.xbframework; + +import android.content.Context; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +public class FileStoreReader { + + public static void saveFile(Context intentContext, String title, String data){ + + // Check if file exists and if not, create + File file = new File(intentContext.getFilesDir(), title); + if(!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // After it is known to exist, open the file stream and try to place data + try { + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(intentContext.openFileOutput(title, Context.MODE_PRIVATE)); + outputStreamWriter.write(data); + outputStreamWriter.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + + + public static String readFile(Context intentContext, String title){ + String ret = ""; + try { + InputStream inputStream = intentContext.openFileInput(title); + + if ( inputStream != null ) { + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + String receiveString = ""; + StringBuilder stringBuilder = new StringBuilder(); + + while ( (receiveString = bufferedReader.readLine()) != null ) { + stringBuilder.append(receiveString); + } + + inputStream.close(); + ret = stringBuilder.toString(); + } + } + catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return ret; + } + + +} diff --git a/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java index 231fc2e1c901629c42038b28da25752e2e635378..00b470484b067fb823448c6eb2bfecfd7533cd08 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/LoginActivity.java @@ -12,26 +12,29 @@ import static android.util.Log.d; public class LoginActivity extends AppCompatActivity { - private Button loginButton, homeButton; - private Toolbar myToolbar; + private Button submitLoginButton, backHomeButton; + private Toolbar toolbar; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); - myToolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); - loginButton=(Button) findViewById(R.id.loginButton); - loginButton.setOnClickListener(new View.OnClickListener(){ + submitLoginButton = (Button) findViewById(R.id.LoginSubmitButton); + submitLoginButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - + //TODO: implement what happens on submitting login } }); - homeButton=(Button) findViewById(R.id.backHomeLogin); - homeButton.setOnClickListener(new View.OnClickListener(){ + backHomeButton = (Button) findViewById(R.id.LoginBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { finish(); } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java index 40c172faa4609058f32aa8304c779d5424dafc44..c90848dc0be676d19bb6d830be8ac2c6860b8cbd 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/MainActivity.java @@ -1,15 +1,27 @@ package com.yearthreeproject.xbframework; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - +import android.Manifest; import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import android.view.View; import android.widget.Button; -import android.content.Intent; +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.util.Random; import static android.util.Log.d; @@ -17,76 +29,173 @@ import static android.util.Log.d; public class MainActivity extends AppCompatActivity { private Button homeButton, loginButton, shopButton, experimentsButton, progressButton, aboutButton; - private Toolbar myToolbar; + private Toolbar toolbar; + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + SharedPreferences savedSettings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); + SharedPreferences.Editor savedSettingsEditor = savedSettings.edit(); + + askForWriteAccess(); + + // 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(); + } + + FileStoreReader.saveFile(this, "boxData.json", boxesData); + + d("file", FileStoreReader.readFile(this, "boxData.json")); - SharedPreferences settings = this.getSharedPreferences("com.yearthreeproject.xbframework.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = settings.edit(); + homeButton = findViewById(R.id.HomeHomeButton); + loginButton = findViewById(R.id.HomeLoginButton); + shopButton = findViewById(R.id.HomeShopButton); + experimentsButton = findViewById(R.id.HomeExperimentsButton); + progressButton = findViewById(R.id.HomeProgressButton); + aboutButton = findViewById(R.id.HomeAboutButton); - if(settings.getString("salt", "").equals("")){ - Random gen = new Random(); - StringBuilder randString = new StringBuilder(); - Character tempChar; + if (savedSettings.getString("salt", "").equals("")) { + Random saltGenerator = new Random(); + StringBuilder saltString = new StringBuilder(); + Character iterativeCharacter; - for(int i = 0; i < 10; i++){ - tempChar = Integer.toString(gen.nextInt(96) + 32).charAt(0); - randString.append(tempChar); + for (int i = 0; i < 10; i++) { + iterativeCharacter = Integer.toString(saltGenerator.nextInt(96) + 32).charAt(0); + saltString.append(iterativeCharacter); } - editor.putString("salt", randString.toString()); - editor.apply(); - } else{ - d("Salt", settings.getString("salt", "")); + savedSettingsEditor.putString("Salt", saltString.toString()); + savedSettingsEditor.apply(); + } else { + d("Salt", savedSettings.getString("Salt", "")); } - homeButton=findViewById(R.id.homeButton); - homeButton.setOnClickListener(new View.OnClickListener(){ + + homeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { d("testing", "homeButton clicked"); } }); - loginButton=findViewById(R.id.loginButton); - loginButton.setOnClickListener(new View.OnClickListener(){ + + loginButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, LoginActivity.class)); } }); - shopButton=findViewById(R.id.shopButton); - shopButton.setOnClickListener(new View.OnClickListener(){ + + shopButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - startActivity(new Intent(MainActivity.this, ShopActivity.class )); + startActivity(new Intent(MainActivity.this, ShopActivity.class)); } }); - experimentsButton=findViewById(R.id.experimentsButton); - experimentsButton.setOnClickListener(new View.OnClickListener(){ + + experimentsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, BoxesActivity.class)); } }); - progressButton=findViewById(R.id.progressButton); - progressButton.setOnClickListener(new View.OnClickListener(){ + + progressButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, ProgressActivity.class)); } }); - aboutButton=findViewById(R.id.aboutButton); - aboutButton.setOnClickListener(new View.OnClickListener(){ + + aboutButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(MainActivity.this, AboutActivity.class)); } }); } -} + + // Image permission check + private void askForWriteAccess() { + 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); + } + }).setNegativeButton("Cancel", null).show(); + + } else { + ActivityCompat.requestPermissions(MainActivity.this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + 1); + } + } else { + d("Perm", "Already granted"); + } + + if (ContextCompat.checkSelfPermission(MainActivity.this, + Manifest.permission.READ_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + + if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, + Manifest.permission.READ_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); + } + }).setNegativeButton("Cancel", null).show(); + + } else { + ActivityCompat.requestPermissions(MainActivity.this, + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + 1); + } + } else { + d("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 new file mode 100644 index 0000000000000000000000000000000000000000..aa7db1ed021e27036191a61dd46b2e410dff78b3 --- /dev/null +++ b/app/src/main/java/com/yearthreeproject/xbframework/NewBox.java @@ -0,0 +1,571 @@ +package com.yearthreeproject.xbframework; + +import android.Manifest; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.graphics.Color; +import android.net.Uri; +import android.os.Bundle; +import android.provider.Settings; +import android.text.InputType; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.theartofdev.edmodo.cropper.CropImage; +import com.theartofdev.edmodo.cropper.CropImageView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import static android.util.Log.d; + + +// TODO: For layout cleanup, look into relative layouts + + +public class NewBox extends AppCompatActivity { + + private Toolbar toolbar; + private Uri imageUploadResultUri; + private List<EditText> groupTitlesArray = new ArrayList(); + private List<List<EditText>> experimentTitlesArray = new ArrayList(); + private List<List<EditText>> experimentDescriptionsArray = new ArrayList(); + private List<List<EditText>> experimentInstructionsArray = new ArrayList(); + private ImageView uploadImageButton; + private int globalGroupIndex = 1; + private String inFiveValue = "Select a MEECS..."; + private boolean imageUploaded = false; + private Toast submitToast; + + // OnCreate (Main thread) + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_new_box); + + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + uploadImageButton = findViewById(R.id.UploadImageButton); + Button backButton = findViewById(R.id.NewBoxBackButton); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + 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.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { + inFiveValue = (String) parent.getItemAtPosition(position); + } + + @Override + public void onNothingSelected(AdapterView<?> parent) { + + } + }); + + uploadImageButton.setMaxHeight(uploadImageButton.getHeight()); + + + uploadImageButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + imagePermissionCheckFunction(); + } + }); + + Button addExperimentButton = findViewById(R.id.GroupOneAddExperimentButton); + addExperimentButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addExperimentFunction(v, 0); + } + }); + + Button submitButton = findViewById(R.id.NewBoxSubmitButton); + Button addGroupButton = findViewById(R.id.AddExperimentGroupButton); + + EditText groupOneTitleEditText = findViewById(R.id.GroupOneTitleEditText); + + groupTitlesArray.add(groupOneTitleEditText); + + submitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + submitNewBoxFunction(); + } + }); + + addGroupButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addGroupFunction(v, globalGroupIndex); + } + }); + + + } + + // Submit function + 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; + toastText = "Need to fill out all the group titles!"; + } + if (experimentTitlesArray.size() > 0) { + for (int j = 0; j < experimentTitlesArray.get(i).size(); j++) { + if (experimentTitlesArray.get(i).get(j).getText().toString().matches("") + || experimentDescriptionsArray.get(i).get(j).getText().toString().matches("") + || experimentInstructionsArray.get(i).get(j).getText().toString().matches("")) { + completedInfo = false; + toastText = "Need to fill out all the experiment information!"; + } + } + } else { + completedInfo = false; + toastText = "Need to have at least one experiment!"; + } + } + + if (experimentTitlesArray.size() < 1){ + completedInfo = false; + toastText = "Need to have at least one experiment!"; + } + + EditText tempEditTextForStringRetrieval = findViewById(R.id.TitleEditText); + if(tempEditTextForStringRetrieval.getText().toString().matches("")){ + completedInfo = false; + toastText = "Need to fill in Box Title!"; + } + tempEditTextForStringRetrieval = findViewById(R.id.BlurbEditText); + if(tempEditTextForStringRetrieval.getText().toString().matches("")){ + completedInfo = false; + toastText = "Need to fill in Box Blurb!"; + } + tempEditTextForStringRetrieval = findViewById(R.id.DescriptionEditText); + if(tempEditTextForStringRetrieval.getText().toString().matches("")){ + completedInfo = false; + toastText = "Need to fill in Box Description!"; + } + tempEditTextForStringRetrieval = findViewById(R.id.WarningEditText); + if(tempEditTextForStringRetrieval.getText().toString().matches("")){ + completedInfo = false; + toastText = "Need to fill in Box Warning!"; + } + + if (inFiveValue.matches("Select a MEECS...")){ + completedInfo = false; + toastText = "Need to select a MEECS for the box to be a part of!"; + } + + if (completedInfo) { + try { + JSONObject box = new JSONObject(); + + tempEditTextForStringRetrieval = findViewById(R.id.TitleEditText); + box.put("Name", tempEditTextForStringRetrieval.getText().toString()); + + box.put("Group", inFiveValue); + + tempEditTextForStringRetrieval = findViewById(R.id.BlurbEditText); + box.put("Blurb", tempEditTextForStringRetrieval.getText().toString()); + + box.put("Locked", true); + + if (imageUploaded) box.put("Image", imageUploadResultUri); + else box.put("Image", ""); + + tempEditTextForStringRetrieval = findViewById(R.id.DescriptionEditText); + box.put("Description", tempEditTextForStringRetrieval.getText().toString()); + + tempEditTextForStringRetrieval = findViewById(R.id.WarningEditText); + box.put("WarningText", tempEditTextForStringRetrieval.getText().toString()); + + JSONArray experimentGroups = new JSONArray(); + for (int i = 0; i < globalGroupIndex; i++) { + JSONObject experimentGroupInfo = new JSONObject(); + + experimentGroupInfo.put("Group", groupTitlesArray.get(i).getText().toString()); + JSONArray groupExperimentList = new JSONArray(); + + for (int j = 0; j < experimentTitlesArray.get(i).size(); j++) { + JSONObject experiment = new JSONObject(); + + experiment.put("Title", experimentTitlesArray.get(i).get(j).getText().toString()); + experiment.put("Instructions", experimentInstructionsArray.get(i).get(j).getText().toString()); + experiment.put("Description", experimentDescriptionsArray.get(i).get(j).getText().toString()); + + groupExperimentList.put(experiment); + } + experimentGroupInfo.put("Options", groupExperimentList); + experimentGroups.put(experimentGroupInfo); + } + box.put("Experiments", experimentGroups); + + Intent openPage = new Intent(NewBox.this, ExperimentSurveyCreatorActivity.class); + openPage.putExtra("JSON", box.toString()); + openPage.putExtra("ExperimentIndex", 0); + openPage.putExtra("GroupIndex", 0); + startActivity(openPage); + } catch (JSONException e) { + e.printStackTrace(); + } + } else { + try { + if (submitToast.getView().isShown()) { + // Do nothing + } else { + // Update when should be shown + submitToast = Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT); + submitToast.show(); + } + } catch (Exception e) { + // First creation + submitToast = Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT); + submitToast.show(); + } + } + } + + // Image permission check + private void imagePermissionCheckFunction() { + if (ContextCompat.checkSelfPermission(NewBox.this, + Manifest.permission.READ_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + + if (ActivityCompat.shouldShowRequestPermissionRationale(NewBox.this, + Manifest.permission.READ_EXTERNAL_STORAGE)) { + + 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); + } + }).setNegativeButton("Cancel", null).show(); + + } else { + ActivityCompat.requestPermissions(NewBox.this, + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + 1); + } + } else { + d("Perm", "Already granted"); + startImageUpload(); + } + } + + // Add group button function + private void addGroupFunction(View v, final int localGroupIndex) { + final LinearLayout experimentInfoLayout = findViewById(R.id.ExperimentsInfoLayout); + + /* + Linear Layout (Vertical) + LL (Horizontal) + LL (Vert1) LL (Vert2) + Text(Group 2) Button(Delete) + Text(Title) TextEdit(Group Title) + Text(Experiments) Button(Add Experiment) + View(HR) + */ + + final LinearLayout experimentGroupLayout = new LinearLayout(NewBox.this); + experimentGroupLayout.setOrientation(LinearLayout.VERTICAL); + + LinearLayout groupSettingsLayout = new LinearLayout(NewBox.this); + groupSettingsLayout.setOrientation(LinearLayout.HORIZONTAL); + + LinearLayout groupDataTextViewLayout = new LinearLayout(NewBox.this); + groupDataTextViewLayout.setOrientation(LinearLayout.VERTICAL); + groupDataTextViewLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); + + LinearLayout groupDataEditTextLayout = new LinearLayout(NewBox.this); + groupDataEditTextLayout.setOrientation(LinearLayout.VERTICAL); + groupDataEditTextLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + + TextView titleTextView = new TextView(NewBox.this); + titleTextView.setText("Title:"); + titleTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); + titleTextView.setGravity(Gravity.CENTER_VERTICAL); + groupDataTextViewLayout.addView(titleTextView); + + final EditText titleEditText = new EditText(NewBox.this); + titleEditText.setHint("Group Title"); + titleEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); + titleEditText.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + + groupTitlesArray.add(titleEditText); + groupDataEditTextLayout.addView(titleEditText); + + Button deleteGroupButton = new Button(NewBox.this); + deleteGroupButton.setText("Delete Group"); + + TextView experimentsTextView = new TextView(NewBox.this); + experimentsTextView.setText("Experiments:"); + experimentsTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); + experimentsTextView.setGravity(Gravity.CENTER_VERTICAL); + groupDataTextViewLayout.addView(experimentsTextView); + + Button addExperimentToGroupButton = new Button(NewBox.this); + addExperimentToGroupButton.setText("Add Experiment"); + addExperimentToGroupButton.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + + addExperimentToGroupButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addExperimentFunction(v, localGroupIndex); + } + }); + + groupDataEditTextLayout.addView(addExperimentToGroupButton); + + groupSettingsLayout.addView(groupDataTextViewLayout); + groupSettingsLayout.addView(groupDataEditTextLayout); + + experimentGroupLayout.addView(groupSettingsLayout); + experimentGroupLayout.addView(deleteGroupButton); + + View hr = new View(NewBox.this); + ViewGroup.LayoutParams hrLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 4); + hr.setLayoutParams(hrLayoutParams); + hr.setBackgroundColor(Color.parseColor("#888888")); + + experimentGroupLayout.addView(hr); + + experimentInfoLayout.addView(experimentGroupLayout); + + 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) { + experimentGroupLayout.removeAllViews(); + groupTitlesArray.remove(titleEditText); + experimentTitlesArray.remove(localGroupIndex); + experimentDescriptionsArray.remove(localGroupIndex); + experimentInstructionsArray.remove(localGroupIndex); + globalGroupIndex--; + } + }).setNegativeButton("No", null) + .show(); + } + }); + + globalGroupIndex++; + } + + // Add experiment button function + private void addExperimentFunction(View v, final int localGroupIndex) { + ViewGroup addExperimentToGroupButtonParent = (ViewGroup) v.getParent(); + addExperimentToGroupButtonParent.removeView(v); + + /* + * LL Vert Overall + * Linear Layout (horizontal) + * LL (vert1) LL (Vert2) + * TitleView TitleEdit + * DescView DescEdit + * InstuctView InstructEdit + * Title Data + * LL (Hor) + * LL (vert1) LL (vert2) + * SurveyView SuveryButton + * Delete Button + * */ + + final LinearLayout experimentDataLayout = new LinearLayout(NewBox.this); + experimentDataLayout.setOrientation(LinearLayout.VERTICAL); + experimentDataLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); + + //d("newGroup", String.valueOf(gI)); + + LinearLayout experimentSettingsLayout = new LinearLayout(NewBox.this); + experimentSettingsLayout.setOrientation(LinearLayout.HORIZONTAL); + experimentSettingsLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); + + LinearLayout experimentSettingsTextViewLayout = new LinearLayout(NewBox.this); + experimentSettingsTextViewLayout.setOrientation(LinearLayout.VERTICAL); + experimentSettingsTextViewLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); + + TextView experimentTitleTextView = new TextView(NewBox.this); + experimentTitleTextView.setText("Title:"); + + TextView experimentDescriptionTextView = new TextView(NewBox.this); + experimentDescriptionTextView.setText("Description:"); + + TextView experimentInstructionsTextView = new TextView(NewBox.this); + experimentInstructionsTextView.setText("Instructions:"); + + experimentSettingsTextViewLayout.addView(experimentTitleTextView); + experimentSettingsTextViewLayout.addView(experimentDescriptionTextView); + experimentSettingsTextViewLayout.addView(experimentInstructionsTextView); + + + LinearLayout experimentSettingsEditTextLayout = new LinearLayout(NewBox.this); + experimentSettingsEditTextLayout.setOrientation(LinearLayout.VERTICAL); + experimentSettingsEditTextLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); + + EditText experimentTitleEditText = new EditText(NewBox.this); + experimentTitleEditText.setHint("Title"); + experimentTitleEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); + + experimentTitlesArray.add(new ArrayList()); + experimentTitlesArray.get(localGroupIndex).add(experimentTitleEditText); + + EditText experimentDescriptionEditText = new EditText(NewBox.this); + experimentDescriptionEditText.setHint("Description"); + experimentDescriptionEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); + + experimentDescriptionsArray.add(new ArrayList()); + experimentDescriptionsArray.get(localGroupIndex).add(experimentDescriptionEditText); + + EditText experimentInstructionsEditText = new EditText(NewBox.this); + experimentInstructionsEditText.setHint("Instructions"); + experimentInstructionsEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); + + experimentInstructionsArray.add(new ArrayList()); + experimentInstructionsArray.get(localGroupIndex).add(experimentInstructionsEditText); + + experimentSettingsEditTextLayout.addView(experimentTitleEditText); + experimentSettingsEditTextLayout.addView(experimentDescriptionEditText); + experimentSettingsEditTextLayout.addView(experimentInstructionsEditText); + + Button deleteExperimentButton = new Button(NewBox.this); + deleteExperimentButton.setText("Delete Experiment"); + deleteExperimentButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ViewGroup deleteExperimentButtonParent = (ViewGroup) v.getParent(); + experimentDataLayout.removeAllViews(); + deleteExperimentButtonParent.removeView(v); + } + }); + + final Button addAnotherExperimentButton = new Button(NewBox.this); + addAnotherExperimentButton.setText("Add Experiment"); + addAnotherExperimentButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addExperimentFunction(v, localGroupIndex); + } + }); + + + experimentSettingsLayout.addView(experimentSettingsTextViewLayout); + experimentSettingsLayout.addView(experimentSettingsEditTextLayout); + experimentDataLayout.addView(experimentSettingsLayout); + + addExperimentToGroupButtonParent.addView(experimentDataLayout); + addExperimentToGroupButtonParent.addView(deleteExperimentButton); + addExperimentToGroupButtonParent.addView(addAnotherExperimentButton); + } + + // Image processing on result + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { + CropImage.ActivityResult result = CropImage.getActivityResult(data); + if (resultCode == RESULT_OK) { + imageUploaded = true; + imageUploadResultUri = result.getUri(); + int maxHeight = uploadImageButton.getHeight(); + uploadImageButton.setImageURI(imageUploadResultUri); + LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + imageLayoutParams.height = maxHeight; + uploadImageButton.setMaxHeight(maxHeight); + uploadImageButton.setLayoutParams(imageLayoutParams); + } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { + Exception error = result.getError(); + Log.e("Error!", String.valueOf(error)); + } + } + } + + // Permission processing + @Override + public void onRequestPermissionsResult(int requestCode, + String[] permissions, int[] grantResults) { + switch (requestCode) { + case 1: { + // If request is cancelled, the result arrays are empty. + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + d("Perm", "granted"); + startImageUpload(); + } else { + 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); + } + }).setNegativeButton("Cancel", null).show(); + } + return; + } + } + } + + // Start image upload + public void startImageUpload() { + CropImage.activity() + .setMinCropResultSize(100, 100) + .setGuidelines(CropImageView.Guidelines.OFF) + .setFixAspectRatio(true) + .start(NewBox.this); + } +} diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java index 1e0acb509e65c3321610d387844974d24cf521c1..3ee0b0fa137bae297e1ce9eaf1cc6b329122dcc6 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ProgressActivity.java @@ -1,6 +1,8 @@ package com.yearthreeproject.xbframework; import android.os.Bundle; +import android.view.View; +import android.widget.Button; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; @@ -8,15 +10,29 @@ import androidx.appcompat.widget.Toolbar; public class ProgressActivity extends AppCompatActivity { - private Toolbar myToolbar; + private Toolbar toolbar; + private Button backHomeButton; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_shop); + setContentView(R.layout.activity_progress); + + // TODO: implement any of this page / class + + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + backHomeButton = findViewById(R.id.ProgressBackHomButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + finish(); + } + }); - myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); } } diff --git a/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java b/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java index e20188d020f9517b2b2608fd3609c936b783f675..fbac9f466f17663f272ff3dd33d5e2027ba2b01d 100644 --- a/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java +++ b/app/src/main/java/com/yearthreeproject/xbframework/ShopActivity.java @@ -1,22 +1,187 @@ package com.yearthreeproject.xbframework; +import android.annotation.SuppressLint; +import android.graphics.Color; +import android.media.Image; +import android.os.Build; import android.os.Bundle; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.GridLayout; +import android.widget.GridLayout.Alignment; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.cardview.widget.CardView; + +import com.google.android.material.snackbar.Snackbar; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import static android.util.Log.d; +import static android.widget.GridLayout.*; public class ShopActivity extends AppCompatActivity { - private Toolbar myToolbar; + private Toolbar toolbar; + private Button backHomeButton; + private Toast attemptToBuyPopup; + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + @SuppressLint("ResourceType") @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shop); - myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); + // TODO: implement more ideas into the data array, but have the functionality on click to express that you cannot buy at the moment + + toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setLogo(R.mipmap.ic_launcher); + getSupportActionBar().setDisplayUseLogoEnabled(true); + + GridLayout shopLayout = findViewById(R.id.ShopContentLayout); + + shopLayout.setAlignmentMode(ALIGN_BOUNDS); + + + InputStream inputStream = getResources().openRawResource(R.raw.shop); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + final JSONArray shopItemsJSONArray; + int ctr; + + + try { + + ctr = inputStream.read(); + while (ctr != -1) { + byteArrayOutputStream.write(ctr); + ctr = inputStream.read(); + } + inputStream.close(); + + // Full loading of json array with each data item included + shopItemsJSONArray = new JSONArray(byteArrayOutputStream.toString()); + + int uniqueId = 1; + + for (int i = 0; i < shopItemsJSONArray.length(); i++) { + JSONObject shopItem = shopItemsJSONArray.getJSONObject(i); + + d("shopitems", shopItem.toString()); + + CardView shopItemCard = new CardView(ShopActivity.this); + + GridLayout.LayoutParams cardParams = new GridLayout.LayoutParams(GridLayout.spec( + UNDEFINED, ALIGN_MARGINS, 1f), + GridLayout.spec(UNDEFINED, ALIGN_MARGINS, 1f)); + + cardParams.setMargins(16, 0, 16, 16); + cardParams.width = 0; + + + shopItemCard.setLayoutParams(cardParams); + + + shopItemCard.setCardBackgroundColor(Color.parseColor("#E6E6E6")); + shopItemCard.setMaxCardElevation((float) 0.0); + shopItemCard.setRadius((float) 5.0); + + RelativeLayout shopItemLL = new RelativeLayout(ShopActivity.this); + + ImageView itemImage = new ImageView(ShopActivity.this); + itemImage.setImageResource(R.mipmap.ic_launcher); + itemImage.setId(uniqueId++); + + TextView itemTitle = new TextView(ShopActivity.this); + itemTitle.setId(uniqueId++); + itemTitle.setText(shopItem.getString("Title")); + + TextView itemDesc = new TextView(ShopActivity.this); + itemDesc.setId(uniqueId++); + itemDesc.setText(shopItem.getString("Blurb")); + + TextView itemPrice = new TextView(ShopActivity.this); + itemPrice.setId(uniqueId++); + itemPrice.setText(Double.toString(shopItem.getDouble("Price"))); + itemPrice.setBackgroundColor(Color.parseColor("#FFFFFF")); + + RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + imageParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); + imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); + imageParams.height = 378; + imageParams.width = 378; + + RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + titleParams.addRule(RelativeLayout.BELOW, itemImage.getId()); + + RelativeLayout.LayoutParams priceParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + priceParams.addRule(RelativeLayout.ALIGN_BOTTOM, itemImage.getId()); + priceParams.addRule(RelativeLayout.ALIGN_RIGHT, itemImage.getId()); + itemPrice.setGravity(Gravity.RIGHT); + + RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + descParams.addRule(RelativeLayout.BELOW, itemTitle.getId()); + + shopItemLL.addView(itemImage, imageParams); + shopItemLL.addView(itemTitle, titleParams); + shopItemLL.addView(itemPrice, priceParams); + shopItemLL.addView(itemDesc, descParams); + + shopItemCard.addView(shopItemLL); + + shopItemCard.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + // Essentially if else, but because it causes a fatal error is try catch + try { + d("attempt", String.valueOf(attemptToBuyPopup.getView().isShown())); + if(attemptToBuyPopup.getView().isShown()){ + // Do nothing + }else { + attemptToBuyPopup.show(); + } + } catch (Exception e){ + attemptToBuyPopup = Toast.makeText(getApplicationContext(), "This item is not available for purchase at the moment", Toast.LENGTH_SHORT); + attemptToBuyPopup.show(); + } + } + }); + + shopLayout.addView(shopItemCard, i); + } + + } catch (JSONException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + backHomeButton = findViewById(R.id.ShopBackHomeButton); + backHomeButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + finish(); + } + }); } } diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 0d025f9bf6b67c63044a36a9ff44fbc69e5c5822..2408e30d1751ecd910eace02fa947f67c0bbd1dd 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,74 @@ <?xml version="1.0" encoding="utf-8"?> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="108dp" +<vector android:height="108dp" + android:width="108dp" + android:viewportHeight="108" android:viewportWidth="108" - android:viewportHeight="108"> - <path - android:fillColor="#008577" - android:pathData="M0,0h108v108h-108z" /> - <path - android:fillColor="#00000000" - android:pathData="M9,0L9,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,0L19,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M29,0L29,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M39,0L39,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M49,0L49,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M59,0L59,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M69,0L69,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M79,0L79,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M89,0L89,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M99,0L99,108" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,9L108,9" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,19L108,19" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,29L108,29" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,39L108,39" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,49L108,49" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,59L108,59" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,69L108,69" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,79L108,79" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,89L108,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M0,99L108,99" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,29L89,29" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,39L89,39" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,49L89,49" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,59L89,59" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,69L89,69" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M19,79L89,79" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M29,19L29,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M39,19L39,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M49,19L49,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M59,19L59,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M69,19L69,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> - <path - android:fillColor="#00000000" - android:pathData="M79,19L79,89" - android:strokeWidth="0.8" - android:strokeColor="#33FFFFFF" /> + xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#008577" + android:pathData="M0,0h108v108h-108z"/> + <path android:fillColor="#00000000" android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> </vector> diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 175f05e59bba3036b84cac65868d588ee288cb9a..e437b9d9d55f9dae95f51fa50a31e026403eea04 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -18,7 +18,7 @@ android:background="@color/colorPrimary" android:minHeight="56dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" - app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> + app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </com.google.android.material.appbar.AppBarLayout> diff --git a/app/src/main/res/layout/activity_experiments_list.xml b/app/src/main/res/layout/activity_experiment.xml similarity index 91% rename from app/src/main/res/layout/activity_experiments_list.xml rename to app/src/main/res/layout/activity_experiment.xml index a639dfb89dbcec6f200dadb21706f76e1efe4dd5..71974df3e8aa24b1f826e0552bfd67bb3c79468a 100644 --- a/app/src/main/res/layout/activity_experiments_list.xml +++ b/app/src/main/res/layout/activity_experiment.xml @@ -4,7 +4,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".ExperimentsListActivity"> + tools:context=".ExperimentActivity"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" @@ -23,7 +23,7 @@ </com.google.android.material.appbar.AppBarLayout> - <include layout="@layout/content_experiments_list" /> + <include layout="@layout/content_experiment" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_experiment_survey_creator.xml b/app/src/main/res/layout/activity_experiment_survey_creator.xml new file mode 100644 index 0000000000000000000000000000000000000000..5eb0e3bc9e6d7dc8b13f092c2e863dd68729ad80 --- /dev/null +++ b/app/src/main/res/layout/activity_experiment_survey_creator.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".ExperimentSurveyCreatorActivity"> + + <com.google.android.material.appbar.AppBarLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorPrimary" + android:minHeight="56dp" + android:theme="@style/ThemeOverlay.AppCompat.ActionBar" + app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> + + </com.google.android.material.appbar.AppBarLayout> + + + <include layout="@layout/content_experiment_survey_creator" /> + + +</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_new_box.xml b/app/src/main/res/layout/activity_new_box.xml new file mode 100644 index 0000000000000000000000000000000000000000..221e698f0e8ebf094d57a55a572245077eba1ea1 --- /dev/null +++ b/app/src/main/res/layout/activity_new_box.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".NewBox"> + + <com.google.android.material.appbar.AppBarLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/colorPrimary" + android:minHeight="56dp" + android:theme="@style/ThemeOverlay.AppCompat.ActionBar" + app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> + + </com.google.android.material.appbar.AppBarLayout> + + + <include layout="@layout/content_new_box" /> + + +</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_about.xml b/app/src/main/res/layout/content_about.xml index bcbe337bd9cde47e897d4eead6bf15732cdebd86..b4758f72261f5181d9ef80c4a9e18736815d9291 100644 --- a/app/src/main/res/layout/content_about.xml +++ b/app/src/main/res/layout/content_about.xml @@ -2,6 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/AboutActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -12,18 +13,33 @@ tools:showIn="@layout/activity_about"> - <TextView - android:id="@+id/aboutParagraph" + <ScrollView + android:id="@+id/AboutScrollView" android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:text="@string/about_about_para" - android:textSize="22sp" /> + android:layout_height="wrap_content" + android:layout_weight="1"> + + <LinearLayout + android:id="@+id/AboutScrollParagraphLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/AboutParagraphTextView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:text="@string/about_about_para" + android:textSize="22sp" /> + </LinearLayout> + </ScrollView> <Button - android:id="@+id/backHomeAbout" + android:id="@+id/AboutBackHomeButton" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0" android:text="@string/about_back_home_button" /> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_boxes.xml b/app/src/main/res/layout/content_boxes.xml index 73ab2e45f30dc00c59a2121a878c0ebe6d46f007..f48e69cd272a08257e08dba58c4d7a2b01258f72 100644 --- a/app/src/main/res/layout/content_boxes.xml +++ b/app/src/main/res/layout/content_boxes.xml @@ -2,7 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/contentExperiments" + android:id="@+id/BoxesActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -13,20 +13,21 @@ tools:showIn="@layout/activity_boxes"> <ScrollView + android:id="@+id/BoxesActivityScrollView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <LinearLayout - android:id="@+id/experimentsGrid" + android:id="@+id/BoxesInFiveLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:weightSum="1"/> + android:weightSum="1" /> </ScrollView> <Button - android:id="@+id/experimentsBackHome" + android:id="@+id/BoxesBackHomeButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/about_back_home_button" /> diff --git a/app/src/main/res/layout/content_experiment.xml b/app/src/main/res/layout/content_experiment.xml new file mode 100644 index 0000000000000000000000000000000000000000..b97fcc6754397f74456d69517a07a15ff485ec0e --- /dev/null +++ b/app/src/main/res/layout/content_experiment.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/ExperimentActivityLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="16dp" + android:layout_marginTop="32dp" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:context=".ExperimentActivity" + tools:showIn="@layout/activity_experiment"> + + <ScrollView + android:id="@+id/ExperimentScrollView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1"> + + <LinearLayout + android:id="@+id/ExperimentInfoLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"></LinearLayout> + + </ScrollView> + + <LinearLayout + android:id="@+id/ExperimentNavigationLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0" + android:orientation="horizontal"> + + <Button + android:id="@+id/ExperimentBackHomeButton" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:text="@string/about_back_home_button" /> + + <Button + android:id="@+id/ExperimentSubmitButton" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:text="@string/experiment_submit" /> + + </LinearLayout> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_experiment_survey_creator.xml b/app/src/main/res/layout/content_experiment_survey_creator.xml new file mode 100644 index 0000000000000000000000000000000000000000..63c597cf0272369263e592d8ccec6f389499202c --- /dev/null +++ b/app/src/main/res/layout/content_experiment_survey_creator.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/ExperimentSurveyActivityLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="16dp" + android:layout_marginTop="32dp" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:context=".ExperimentSurveyCreatorActivity" + tools:showIn="@layout/activity_experiment_survey_creator"> + + <ScrollView + android:id="@+id/SurveyScroll" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1"> + + <LinearLayout + android:id="@+id/SurveyCreationLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"></LinearLayout> + + </ScrollView> + + <LinearLayout + android:id="@+id/ExperimentSurveyNavigationLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0" + android:orientation="horizontal"> + + <Button + android:id="@+id/ExperimentSurveyCreatorBackHomeButton" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:text="@string/about_back_home_button" /> + + <Button + android:id="@+id/ExperimentSurveyCreatorSubmitButton" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:text="@string/next" /> + + </LinearLayout> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_experiments_list.xml b/app/src/main/res/layout/content_experiments_list.xml deleted file mode 100644 index a41ea5cbf4e7770ab49fc4708e6945bb2646fd67..0000000000000000000000000000000000000000 --- a/app/src/main/res/layout/content_experiments_list.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/experimentObjectContent" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_margin="16dp" - android:layout_marginTop="32dp" - android:orientation="vertical" - app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context=".ExperimentsListActivity" - tools:showIn="@layout/activity_experiments_list"> - - <ScrollView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_weight="1"> - - <LinearLayout - android:id="@+id/experimentLayout" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - - </LinearLayout> - </ScrollView> - - <Button - android:id="@+id/experimentSubmit" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:text="@string/experiment_submit" /> - - <Button - android:id="@+id/experimentsBackHome" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:text="@string/about_back_home_button" /> - -</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_login.xml b/app/src/main/res/layout/content_login.xml index 24f08e9a37b2aa17fde8714b64f7dd59c503918d..93e1e32a9c8020bf6fcd59aaa682a8b916f274d4 100644 --- a/app/src/main/res/layout/content_login.xml +++ b/app/src/main/res/layout/content_login.xml @@ -2,6 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/LoginActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -13,25 +14,27 @@ <LinearLayout + android:id="@+id/LoginFieldLayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <LinearLayout + android:id="@+id/EmailLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView - android:id="@+id/emailLabel" + android:id="@+id/EmailTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/login_email" /> <EditText - android:id="@+id/emailInput" + android:id="@+id/EmailEditText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" @@ -42,19 +45,20 @@ </LinearLayout> <LinearLayout + android:id="@+id/PasswordLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView - android:id="@+id/passwordLabel" + android:id="@+id/PasswordTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/login_password" /> <EditText - android:id="@+id/passwordInput" + android:id="@+id/PasswordEditText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" @@ -65,14 +69,14 @@ </LinearLayout> <Button - android:id="@+id/loginButton" + android:id="@+id/LoginSubmitButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/login_login_button" /> </LinearLayout> <Button - android:id="@+id/backHomeLogin" + android:id="@+id/LoginBackHomeButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/about_back_home_button" /> diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 665901db3e43773ca1e49fefe8b21dee759543b0..dca05c4a72a7005d32e39e2941ba04f768cdf2b1 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -2,6 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/HomeActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -12,42 +13,42 @@ tools:showIn="@layout/activity_main"> <Button - android:id="@+id/homeButton" + android:id="@+id/HomeHomeButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/main_home" /> <Button - android:id="@+id/loginButton" + android:id="@+id/HomeLoginButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/main_login" /> <Button - android:id="@+id/shopButton" + android:id="@+id/HomeShopButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/main_shop" /> <Button - android:id="@+id/experimentsButton" + android:id="@+id/HomeExperimentsButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/main_experiments" /> <Button - android:id="@+id/progressButton" + android:id="@+id/HomeProgressButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/main_progress" /> <Button - android:id="@+id/aboutButton" + android:id="@+id/HomeAboutButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" diff --git a/app/src/main/res/layout/content_new_box.xml b/app/src/main/res/layout/content_new_box.xml new file mode 100644 index 0000000000000000000000000000000000000000..5c12eb7977a053c2499f1600aa43ea4c7d90b86f --- /dev/null +++ b/app/src/main/res/layout/content_new_box.xml @@ -0,0 +1,288 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/NewBoxActivityLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_margin="16dp" + android:layout_marginTop="32dp" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + tools:context=".NewBox" + tools:showIn="@layout/activity_new_box"> + + <TextView + android:id="@+id/CreateBoxTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Create a new Box" + android:textSize="36sp" + android:textStyle="bold" + android:typeface="sans" /> + + <View + android:id="@+id/hr1" + android:layout_width="match_parent" + android:layout_height="2dp" + android:background="#000000" /> + + <ScrollView + android:id="@+id/DataInputScrollView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1"> + + <LinearLayout + android:id="@+id/InputDataScrollableLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/BoxInfoLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal"> + + <LinearLayout + android:id="@+id/BoxDataTextViewLayout" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/TitleTextView" + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Title:" /> + + <TextView + android:id="@+id/textView" + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Blurb:" /> + + <TextView + android:id="@+id/DescriptionTextView" + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Description:" /> + + <TextView + android:id="@+id/WarningTextView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Warning:" /> + + <TextView + android:id="@+id/ImageTextView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Image:" /> + + <TextView + android:id="@+id/MEECSTextView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="MEECS:" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/BoxDataInputLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <EditText + android:id="@+id/TitleEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ems="10" + android:hint="Box Title" + android:inputType="textPersonName" + android:text="Title" /> + + <EditText + android:id="@+id/BlurbEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ems="10" + android:hint="Very short description " + android:inputType="textPersonName" + android:text="Description" /> + + <EditText + android:id="@+id/DescriptionEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ems="10" + android:hint="Description" + android:inputType="textPersonName" + android:text="Longer Description" /> + + <EditText + android:id="@+id/WarningEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ems="10" + android:hint="Warning" + android:inputType="textPersonName" + android:text="Warning Text" /> + + <ImageView + android:id="@+id/UploadImageButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + app:srcCompat="@mipmap/ic_launcher" /> + + <Spinner + android:id="@+id/MEECSSpinner" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" /> + + </LinearLayout> + + </LinearLayout> + + <View + android:id="@+id/hr2" + android:layout_width="match_parent" + android:layout_height="2dp" + android:layout_weight="1" + android:background="#000000" /> + + <LinearLayout + android:id="@+id/ExperimentsInfoLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/GroupOneLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/CreateExperimentTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Experiments in the Box" + android:textSize="36sp" + android:textStyle="bold" + android:typeface="sans" /> + + <LinearLayout + android:id="@+id/GroupOneSettingsLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal"> + + <LinearLayout + android:id="@+id/GroupOneDataTextViewLayout" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/GroupOneTitleTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Title:" /> + + <TextView + android:id="@+id/GroupOneExperimentsTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center_vertical" + android:text="Experiments:" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/GroupOneDataInputLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <EditText + android:id="@+id/GroupOneTitleEditText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ems="10" + android:hint="Group Title" + android:inputType="textPersonName" + android:text="Group One Title" /> + + <Button + android:id="@+id/GroupOneAddExperimentButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Add Experiment" /> + + </LinearLayout> + </LinearLayout> + </LinearLayout> + + <View + android:id="@+id/hr3" + android:layout_width="match_parent" + android:layout_height="2dp" + android:layout_weight="1" + android:background="#000000" /> + </LinearLayout> + + <Button + android:id="@+id/AddExperimentGroupButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Add Another Group" /> + + </LinearLayout> + </ScrollView> + + <LinearLayout + android:id="@+id/NewBoxNavigationLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0" + android:orientation="horizontal"> + + <Button + android:id="@+id/NewBoxBackButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Back" /> + + <Button + android:id="@+id/NewBoxSubmitButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="Submit" /> + </LinearLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_progress.xml b/app/src/main/res/layout/content_progress.xml index 0ae0e3539fa3de546d9229fe97485763d2a567da..e2d7b805bb4e9170eca919880b5f5020c7436155 100644 --- a/app/src/main/res/layout/content_progress.xml +++ b/app/src/main/res/layout/content_progress.xml @@ -2,6 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/ProgressActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -11,17 +12,30 @@ tools:context=".ProgressActivity" tools:showIn="@layout/activity_progress"> - <LinearLayout + <ScrollView + android:id="@+id/ProgressScrollView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="1" - android:orientation="vertical"> + android:layout_weight="1"> - </LinearLayout> + <LinearLayout + android:id="@+id/ContentContainerLayout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/ProgressPlaceholderTextView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="TextView" /> + </LinearLayout> + </ScrollView> <Button - android:id="@+id/backHomeProgress" + android:id="@+id/ProgressBackHomButton" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0" android:text="@string/about_back_home_button" /> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/content_shop.xml b/app/src/main/res/layout/content_shop.xml index ebf8fe57d5ac6598fbb6d5abc4c01edbcd1b9e68..c62f57e5b411e59f7a0c957ddfb9982c5deef71c 100644 --- a/app/src/main/res/layout/content_shop.xml +++ b/app/src/main/res/layout/content_shop.xml @@ -2,6 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/ShopActivityLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" @@ -11,18 +12,28 @@ tools:context=".ShopActivity" tools:showIn="@layout/activity_shop"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_weight="1" - android:orientation="vertical"> + <ScrollView + android:id="@+id/ShopScrollView" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1"> - </LinearLayout> + <GridLayout + android:id="@+id/ShopContentLayout" + android:layout_width="378dp" + android:layout_height="0dp" + android:columnCount="2" + android:layout_weight="8" + android:rowCount="5" + android:padding="14sp" + /> + </ScrollView> <Button - android:id="@+id/backHomeProgress" + android:id="@+id/ShopBackHomeButton" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0" android:text="@string/about_back_home_button" /> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cfe52eac1ba66ba280a68ca7be8fcf88a16..c4a603d4cce78b2fbd8094bd0224d4778bc8c976 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> - <background android:drawable="@drawable/ic_launcher_background" /> - <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> </adaptive-icon> \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index eca70cfe52eac1ba66ba280a68ca7be8fcf88a16..c4a603d4cce78b2fbd8094bd0224d4778bc8c976 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> - <background android:drawable="@drawable/ic_launcher_background" /> - <foreground android:drawable="@drawable/ic_launcher_foreground" /> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> </adaptive-icon> \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 898f3ed59ac9f3248734a00e5902736c9367d455..26a1ce80cbdc3b587fad4131d7aeb839b245068f 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..5007454a0692293809504d481afb723d64fde139 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index dffca3601eba7bf5f409bdd520820e2eb5122c75..51afdbf5de7551a7b65bc29b8e6f10c4aafbd09f 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 64ba76f75e9ce021aa3d95c213491f73bcacb597..22b58ae416efe0de3375a018d947649afc6228ba 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..7dbecdd696a450b49574ab72bc15ebe79888ca88 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index dae5e082342fcdeee5db8a6e0b27028e2d2808f5..e1b447aa39a423846795880b202a88b7bcff5e13 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index e5ed46597ea8447d91ab1786a34e30f1c26b18bd..025197d56a5840589bbc866898e9d4cfed406f4c 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..269ceef95d369216e3b5bab3a3876973f7819459 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index 14ed0af35023e4f1901cf03487b6c524257b8483..d60b6434bf015cfb0fff5dec77e6df36cc9cb36f 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index b0907cac3bfd8fbfdc46e1108247f0a1055387ec..1fdf476efee107159da7a8e6cc0eced18c7793f7 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..cdf0ce118953d7fd93806d26ffd0c658ba03d332 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index d8ae03154975f397f8ed1b84f2d4bf9783ecfa26..dd1d658e7bcfb70f99d08cbd8d3f54e698ed7c69 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 2c18de9e66108411737e910f5c1972476f03ddbf..7a88ed816832f2457fe5c1a9ae6af6bf0f5347a9 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..2c9615a66b88aed2a54eebbff21b35912f8df89f Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index beed3cdd2c32af5114a7dc70b9ef5b698eb8797e..5a08b3ccd00cd585694939acd492efb025ee354e 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/raw/box.json b/app/src/main/res/raw/box.json index 46d81e15d8227cd6bf1bc79eba7435d9352face7..5c2ec606074501f6e4abc5515a09fefd3df2e4f5 100644 --- a/app/src/main/res/raw/box.json +++ b/app/src/main/res/raw/box.json @@ -1,70 +1,108 @@ [{ + "Name": "Move Box", "Group": "Move", - "Box": [{ - "Name": "Move Box", - "Locked": true, - "Image": null, - "Experiments": [null] - }] - },{ + "Blurb": "This box focuses on movement", + "Locked": true, + "Image": null, + "Experiments": [null] + }, + { + "Name": "Eat Box 1", "Group": "Eat", - "Box": [{ - "Name": "Eat Box 1", - "Locked": true, - "Image": null, - "Experiments": [null] - },{ - "Name": "Eat Box 2", - "Locked": true, - "Image": null, - "Experiments": [null] - }] - },{ + "Blurb": "This box focuses on movement", + "Locked": true, + "Image": null, + "Experiments": [null] + }, + { + "Name": "Eat Box 2", + "Group": "Eat", + "Blurb": "This box focuses on movement", + "Locked": true, + "Image": null, + "Experiments": [null] + }, + { + "Name": "Engage Box", "Group": "Engage", - "Box": [{ - "Name": "Engage Box", - "Locked": true, - "Image": null, - "Experiments": [null] - }] - },{ + "Blurb": "This box focuses on movement", + "Locked": true, + "Image": null, + "Experiments": [null] + }, + { + "Name": "Cogitate Box", "Group": "Cogitate", - "Box": [{ - "Name": "Cogitate Box", - "Locked": true, - "Image": null, - "Experiments": [null] - }] - },{ + "Blurb": "This box focuses on movement", + "Locked": true, + "Image": null, + "Experiments": [null] + }, + { + "Name": "SleepBetter", "Group": "Sleep", - "Box": [{ - "Name": "SleepBetter", - "Locked": false, - "Image": null, - "Description": "These are the next factors and associated experiments that impact your sleep hygiene. The chosen experiment is the one you chose to follow.", - "WarningText": "Please bare in mind that after clicking Submit, you will only be able to change your experiment after 5 days.", - "Experiments": [{ - "Group": "Light", - "Options": ["Increase bright light exposure during the day", - "Wear glasses/a sleeping mask that block blue light during the night", - "Turn off any bright lights 22 hours before going to bed (such as TV/the computer etc)"] + "Blurb": "A faithful recreation of the sleep box application for demonstration", + "Locked": false, + "Image": null, + "Description": "These are the next factors and associated experiments that impact your sleep hygiene. The chosen experiment is the one you chose to follow.", + "WarningText": "Please bare in mind that after clicking Submit, you will only be able to change your experiment after 5 days.", + "Experiments": [{ + "Group": "Light", + "Options": [{ + "Title": "Increase bright light exposure during the day", + "Instructions": "Null for now", + "Description:": "Null for now" + },{ + "Title": "Wear glasses/a sleeping mask that block blue light during the night", + "Instructions": "Null for now", + "Description:": "Null for now" },{ - "Group": "Caffeine", - "Options": ["Do not drink caffeine during the 6 hours before sleep", - "Limit yourself to 4 cups of coffees per day; 10 cans of coke/fanta; 2 energy drinks", - "Do not drink caffeine on an empty stomach"] + "Title": "Turn off any bright lights 22 hours before going to bed (such as TV/the computer etc)", + "Instructions": "Null for now", + "Description:": "Null for now" + } + ] + },{ + "Group": "Caffeine", + "Options": [{ + "Title": "Do not drink caffeine during the 6 hours before sleep", + "Instructions": "Null for now", + "Description:": "Null for now" },{ - "Group": "Sleep Schedule", - "Options": ["Usually get up at the same time everyday, even on weekends/vacations", - "Sleep no less than 7 hours per night", - "Do not go to bed unless you are tired. If you are not, relax with a bath/ by reading a book before bed", - "Go to sleep at 22:30 PM at the latest"] + "Title": "Limit yourself to 4 cups of coffees per day; 10 cans of coke/fanta; 2 energy drinks", + "Instructions": "Null for now", + "Description:": "Null for now" + },{ + "Title": "Do not drink caffeine on an empty stomach", + "Instructions": "Null for now", + "Description:": "Null for now" }] },{ - "Name": "Sleep Box 2", - "Locked": true, - "Image": null, - "Description": "Test description!" + "Group": "Sleep Schedule", + "Options": [{ + "Title": "Usually get up at the same time everyday, even on weekends/vacations", + "Instructions": "Null for now", + "Description:": "Null for now" + },{ + "Title": "Sleep no less than 7 hours per night", + "Instructions": "Null for now", + "Description:": "Null for now" + },{ + "Title": "Do not go to bed unless you are tired. If you are not, relax with a bath/ by reading a book before bed", + "Instructions": "Null for now", + "Description:": "Null for now" + },{ + "Title": "Go to sleep at 22:30 PM at the latest", + "Instructions": "Null for now", + "Description:": "Null for now" + }] }] - } -] \ No newline at end of file + }, + { + "Name": "Sleep Box 2", + "Group": "Sleep", + "Blurb": "A box that focuses on sleeping", + "Locked": true, + "Image": null, + "Description": "Test description!" +}] \ No newline at end of file diff --git a/app/src/main/res/raw/logo.png b/app/src/main/res/raw/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..46e43d3712341a30144c7cafa1545c10e1b5261f Binary files /dev/null and b/app/src/main/res/raw/logo.png differ diff --git a/app/src/main/res/raw/shop.json b/app/src/main/res/raw/shop.json new file mode 100644 index 0000000000000000000000000000000000000000..00a348a28e8abf8e45584af4a54fa260ac1e1134 --- /dev/null +++ b/app/src/main/res/raw/shop.json @@ -0,0 +1,8 @@ +[{ + "Title": "Salt Shaker with stealth camera", + "Image": null, + "Blurb": "A salt shaker with an included camera to capture images of food", + "Description": "A salt shaker with the capability to take an image of your food without you thinking. Perfect for boxes concerning eating, and could enhance the quality of data collected.", + "Price": 14.99, + "Locked": true +}] \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 0000000000000000000000000000000000000000..3ade54a0df005c458ce9cea798de08ada403bc86 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string-array name="meecs" > + <item>Select a MEECS...</item> + <item>Movement</item> + <item>Eating</item> + <item>Engaging</item> + <item>Cogitate</item> + <item>Sleep</item> + + </string-array> +</resources> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 69b22338c6510250df3b43672635120dbce2fa49..67236799f2c7aeb0167e647f82d30a065617e297 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <color name="colorPrimary">#008577</color> - <color name="colorPrimaryDark">#00574B</color> - <color name="colorAccent">#D81B60</color> + <color name="colorPrimary">#587B7F</color> + <color name="colorPrimaryDark">#393E41</color> + <color name="colorAccent">#000000</color> + <color name="colorSecondary">#D3D0CB</color> </resources> diff --git a/app/src/main/res/values/idValues.xml b/app/src/main/res/values/idValues.xml new file mode 100644 index 0000000000000000000000000000000000000000..31f40c4a3de08ec36274e050b34764f2846d7bd9 --- /dev/null +++ b/app/src/main/res/values/idValues.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <item type='id' name="newExperimentGroup1Name"/> + +</resources> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab929fa7b8b74c0c6d00c1fbe7eb3da6cf7fa70b..978d13613ba24f3e3280cedb32dc781777a0aa03 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,7 +9,7 @@ <string name="main_home">Home</string> <string name="main_login">Login</string> <string name="main_shop">Artefact Shop</string> - <string name="main_experiments">Experiments</string> + <string name="main_experiments">Boxes</string> <string name="main_progress">Progress</string> <string name="main_about">About</string> @@ -34,5 +34,6 @@ <string name="experiments_placeholder_image">Example of image description</string> <string name="experiment_submit">Submit</string> + <string name="next">Next</string> </resources> diff --git a/build.gradle b/build.gradle index fb516be20b52a824110a39d1478442083f4d417b..a5bb81578abe36e0900d497fb65028c4d22880bd 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' + classpath 'com.android.tools.build:gradle:3.5.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/key b/key new file mode 100644 index 0000000000000000000000000000000000000000..463665d54fccd54ae2952dc62fa5433ba179cac5 --- /dev/null +++ b/key @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACALD93Of+nWlW2uyXlDdVehR9r1j9lJpcCT2W2E+iqEIAAAAJjN9Ob6zfTm ++gAAAAtzc2gtZWQyNTUxOQAAACALD93Of+nWlW2uyXlDdVehR9r1j9lJpcCT2W2E+iqEIA +AAAEC+A4Vv6whpeR3DUWJpVsHsxZ8KAWamGY/SMVqrKWugBQsP3c5/6daVba7JeUN1V6FH +2vWP2UmlwJPZbYT6KoQgAAAAE2VjdDF1MTdAc290b24uYWMudWsBAg== +-----END OPENSSH PRIVATE KEY----- diff --git a/key.pub b/key.pub new file mode 100644 index 0000000000000000000000000000000000000000..b6efc87aa287c2c709e727e03b361f0c2f22e965 --- /dev/null +++ b/key.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAsP3c5/6daVba7JeUN1V6FH2vWP2UmlwJPZbYT6KoQg ect1u17@soton.ac.uk