Compare commits
No commits in common. "82d4195dd221cf7a33bf1bb346404b514d25ca16" and "90c6f055dd58017d84d155a0f133b616202e25d1" have entirely different histories.
82d4195dd2
...
90c6f055dd
|
|
@ -10,7 +10,7 @@
|
|||
<component name="VisualizationToolProject">
|
||||
<option name="state">
|
||||
<ProjectState>
|
||||
<option name="scale" value="0.045764362220058426" />
|
||||
<option name="scale" value="0.22" />
|
||||
</ProjectState>
|
||||
</option>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
android:exported="false"
|
||||
android:label="@string/title_activity_notes"/>
|
||||
<activity android:name=".main.MainActivity"/>
|
||||
|
||||
<activity android:name=".quiz.QuizActivity"/>
|
||||
<activity android:name=".dice.DiceActivity"/>
|
||||
<activity
|
||||
android:name=".login.LoginActivity"
|
||||
android:exported="true">
|
||||
|
|
|
|||
|
|
@ -5,8 +5,5 @@ public enum BtnID {
|
|||
EDIT_BUTTON,
|
||||
DELETE_BUTTON,
|
||||
NOTES_BUTTON,
|
||||
QUIZ_BUTTON,
|
||||
DICE_BUTTON,
|
||||
BACKGROUND_BUTTON
|
||||
|
||||
QUIZ_BUTTON
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
package xyz.r0r5chach.cpsAssist.dice;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.R;
|
||||
|
||||
public class BtnOnClickListener implements View.OnClickListener{
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinearLayout l = (LinearLayout) v.getParent();
|
||||
Random rand = new Random();
|
||||
TextView output = l.findViewById(R.id.dice_output);
|
||||
EditText input = l.findViewById(R.id.dice_input);
|
||||
output.setText(String.valueOf(rand.nextInt(Integer.parseInt(input.getText().toString()))));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package xyz.r0r5chach.cpsAssist.dice;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.R;
|
||||
|
||||
public class DiceActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dice);
|
||||
setTitle("Dice Roller- " + getIntent().getStringExtra("username"));
|
||||
if (getIntent().hasExtra("background")) {
|
||||
findViewById(R.id.dice_layout).setBackgroundColor(Color.parseColor(getIntent().getStringExtra("background")));
|
||||
}
|
||||
findViewById(R.id.dice_roll_button).setOnClickListener(new BtnOnClickListener());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,29 +2,17 @@ package xyz.r0r5chach.cpsAssist.main;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.BtnID;
|
||||
import xyz.r0r5chach.cpsAssist.dice.DiceActivity;
|
||||
import xyz.r0r5chach.cpsAssist.R;
|
||||
import xyz.r0r5chach.cpsAssist.quiz.QuizActivity;
|
||||
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
||||
|
||||
public class BtnOnClickListener implements View.OnClickListener{
|
||||
private String backgroundColor;
|
||||
|
||||
public BtnOnClickListener() {
|
||||
backgroundColor = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinearLayout l = (LinearLayout) v.getParent();
|
||||
String id = v.getResources().getResourceName(v.getId()).split("/")[1];
|
||||
Intent intent = null;
|
||||
switch(BtnID.valueOf(id.toUpperCase(Locale.ROOT))) {
|
||||
|
|
@ -34,21 +22,10 @@ public class BtnOnClickListener implements View.OnClickListener{
|
|||
case QUIZ_BUTTON:
|
||||
intent = new Intent(v.getContext(), QuizActivity.class);
|
||||
break;
|
||||
case DICE_BUTTON:
|
||||
intent = new Intent(v.getContext(), DiceActivity.class);
|
||||
break;
|
||||
case BACKGROUND_BUTTON:
|
||||
Random rand = new Random();
|
||||
backgroundColor = String.format("#%06x", rand.nextInt(0xffffff + 1));
|
||||
l.setBackgroundColor(Color.parseColor(backgroundColor));
|
||||
break;
|
||||
}
|
||||
Activity main = (Activity) v.getContext();
|
||||
if (intent != null) {
|
||||
intent.putExtra("username", main.getIntent().getStringExtra("username"));
|
||||
if (backgroundColor != null) {
|
||||
intent.putExtra("background", backgroundColor);
|
||||
}
|
||||
main.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.r0r5chach.cpsAssist.main;
|
||||
|
||||
import android.media.MediaDrm;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
|
@ -14,19 +13,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
setTitle("Home- " + getIntent().getStringExtra("username"));
|
||||
initButtons();
|
||||
findViewById(R.id.notes_button).setOnClickListener(new BtnOnClickListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finish();
|
||||
} //TODO: Add change background button to layout and add logic to listner
|
||||
|
||||
private void initButtons() {
|
||||
BtnOnClickListener lstn = new BtnOnClickListener();
|
||||
findViewById(R.id.notes_button).setOnClickListener(lstn);
|
||||
findViewById(R.id.quiz_button).setOnClickListener(lstn);
|
||||
findViewById(R.id.background_button).setOnClickListener(lstn);
|
||||
findViewById(R.id.dice_button).setOnClickListener(lstn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -19,9 +18,6 @@ public class NotesActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_notes);
|
||||
initRecycler();
|
||||
setTitle("Notes- " + getIntent().getStringExtra("username"));
|
||||
if (getIntent().hasExtra("background")) {
|
||||
findViewById(R.id.notes_layout).setBackgroundColor(Color.parseColor(getIntent().getStringExtra("background")));
|
||||
}
|
||||
findViewById(R.id.add_Button).setOnClickListener(new BtnOnClickListener(adapter));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package xyz.r0r5chach.cpsAssist.quiz;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.R;
|
||||
|
||||
public class BtnOnClickListener implements View.OnClickListener{
|
||||
private final String[] correctAnswers;
|
||||
|
||||
|
||||
public BtnOnClickListener(String[] correctAnswers) {
|
||||
this.correctAnswers = correctAnswers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinearLayout l = (LinearLayout) v.getParent();
|
||||
RadioGroup[] questions = new RadioGroup[]{l.findViewById(R.id.question1), l.findViewById(R.id.question2), l.findViewById(R.id.question3), l.findViewById(R.id.question4), l.findViewById(R.id.question5)};
|
||||
int score = 0;
|
||||
for (int i = 0; i < questions.length; i++) {
|
||||
if (questions[i].getCheckedRadioButtonId() == -1) {
|
||||
continue;
|
||||
}
|
||||
RadioButton answer = questions[i].findViewById(questions[i].getCheckedRadioButtonId());
|
||||
if (answer.getText().toString().equals(correctAnswers[i])) {
|
||||
score++;
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
|
||||
builder.setTitle("Results");
|
||||
builder.setMessage(score + "/5");
|
||||
builder.setPositiveButton("Save", new DialogOnClickListener(((Activity)v.getContext()).getIntent().getStringExtra("username"), score));
|
||||
builder.setNeutralButton("Ok", new DialogOnClickListener());
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package xyz.r0r5chach.cpsAssist.quiz;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.notes.Notes;
|
||||
|
||||
public class DialogOnClickListener implements DialogInterface.OnClickListener {
|
||||
private String username;
|
||||
private int score;
|
||||
|
||||
|
||||
public DialogOnClickListener() {
|
||||
|
||||
}
|
||||
|
||||
public DialogOnClickListener(String username, int score) {
|
||||
this.score = score;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
AlertDialog d = (AlertDialog) dialog;
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
Notes notes = new Notes(d.getContext().getExternalFilesDir(null), username);
|
||||
notes.createNote();
|
||||
File note = notes.getNote(notes.getAmount()-1);
|
||||
notes.updateNote(note, "Quiz Results: " + score + "/5");
|
||||
}
|
||||
d.dismiss();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
package xyz.r0r5chach.cpsAssist.quiz;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Quiz {
|
||||
private final String[] questions;
|
||||
|
||||
private String[] correctAnswers;
|
||||
|
||||
private final List<List<String>> answers;
|
||||
|
||||
private final String storedCorrectAnswers;
|
||||
private final String storedIncorrectAnswers;
|
||||
|
||||
public Quiz(String storedQuestions, String storedCorrectAnswers, String storedIncorrectAnswers) {
|
||||
questions = parseList(storedQuestions);
|
||||
answers = new ArrayList<>();
|
||||
this.storedCorrectAnswers = storedCorrectAnswers;
|
||||
this.storedIncorrectAnswers = storedIncorrectAnswers;
|
||||
parseAnswers();
|
||||
|
||||
}
|
||||
|
||||
public String[] getCorrectAnswers() {
|
||||
return correctAnswers;
|
||||
}
|
||||
|
||||
public String[] getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
public List<List<String>> getAnswers() {
|
||||
return answers;
|
||||
}
|
||||
|
||||
private void parseAnswers() {
|
||||
correctAnswers = parseList(storedCorrectAnswers);
|
||||
String[] incorrectAnswers = parseList(storedIncorrectAnswers);
|
||||
for (int i = 0; i < incorrectAnswers.length; i++) {
|
||||
List<String> answers = new ArrayList<>();
|
||||
answers.add(correctAnswers[i]);
|
||||
answers.addAll(Arrays.asList(incorrectAnswers[i].split("%")));
|
||||
this.answers.add(answers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String[] parseList(String list) {
|
||||
return list.split("#");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +1,4 @@
|
|||
package xyz.r0r5chach.cpsAssist.quiz;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import xyz.r0r5chach.cpsAssist.R;
|
||||
|
||||
public class QuizActivity extends AppCompatActivity {
|
||||
private Quiz quiz;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_quiz);
|
||||
setTitle("Quiz- " + getIntent().getStringExtra("username"));
|
||||
if (getIntent().hasExtra("background")) {
|
||||
findViewById(R.id.quiz_layout).setBackgroundColor(Color.parseColor(getIntent().getStringExtra("background")));
|
||||
}
|
||||
LinearLayout layout = findViewById(R.id.quiz_layout);
|
||||
quiz = new Quiz(getString(R.string.questions), getString(R.string.correct_answers), getString(R.string.incorrect_answers));
|
||||
initQuestions(layout);
|
||||
initSubmit(layout);
|
||||
}
|
||||
|
||||
private void initSubmit(LinearLayout l) {
|
||||
Button button = new Button(this);
|
||||
button.setText(R.string.submit_button_text);
|
||||
button.setOnClickListener(new BtnOnClickListener(quiz.getCorrectAnswers()));
|
||||
l.addView(button);
|
||||
}
|
||||
|
||||
|
||||
private void initQuestions(LinearLayout l) {
|
||||
IntStream.range(0, quiz.getQuestions().length).forEach(i -> {
|
||||
RadioGroup questionGroup = new RadioGroup(this);
|
||||
int id = getId(i);
|
||||
questionGroup.setId(id);
|
||||
TextView question = new TextView(this);
|
||||
question.setText(quiz.getQuestions()[i]);
|
||||
questionGroup.addView(question);
|
||||
for (String answer : quiz.getAnswers().get(i)) {
|
||||
RadioButton answerButton = new RadioButton(this);
|
||||
answerButton.setText(answer);
|
||||
questionGroup.addView(answerButton);
|
||||
}
|
||||
l.addView(questionGroup);
|
||||
});
|
||||
}
|
||||
|
||||
private int getId(int index) {
|
||||
int id;
|
||||
switch(index) {
|
||||
case 0:
|
||||
id = R.id.question1;
|
||||
break;
|
||||
case 1:
|
||||
id = R.id.question2;
|
||||
break;
|
||||
case 2:
|
||||
id = R.id.question3;
|
||||
break;
|
||||
case 3:
|
||||
id = R.id.question4;
|
||||
break;
|
||||
case 4:
|
||||
id = R.id.question5;
|
||||
break;
|
||||
default:
|
||||
id = 0;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
public class QuizActivity {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/dice_layout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dice_output"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dice_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints=""
|
||||
android:ems="10"
|
||||
android:hint="@string/dice_hint"
|
||||
android:inputType="number"
|
||||
android:minHeight="48dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/dice_roll_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dice_button_text" />
|
||||
</LinearLayout>
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/main_layout"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
|
|
@ -16,15 +15,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quiz_button_text" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/background_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/change_background_button_text" />
|
||||
<Button
|
||||
android:id="@+id/dice_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dice_roller_button_text"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/notes_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/quiz_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quiz_button_text" />
|
||||
</LinearLayout>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.CpsAssist" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
|
|
@ -13,4 +13,8 @@
|
|||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="edit_dialog">
|
||||
<item name="android:background">@color/white</item>
|
||||
<item name="android:textColor">@color/black</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="question" type="id" />
|
||||
<item name="question1" type="id" />
|
||||
<item name="question2" type="id" />
|
||||
<item name="question3" type="id" />
|
||||
<item name="question4" type="id" />
|
||||
<item name="question5" type="id"/>
|
||||
</resources>
|
||||
|
|
@ -5,20 +5,12 @@
|
|||
<string name="passwordFieldHint">Password</string>
|
||||
<string name="loginButtonText">Login</string>
|
||||
<string name="users">josh#pass%kofi#pass%jaiwin#pass</string>
|
||||
<string name="questions">What is the capital of the UK?#What is the electron count of helium?#What does RAM stand for?#What is the boiling point of water?#When did WWII end?</string>
|
||||
<string name="correct_answers">London#2#Random Access Memory#100 degrees celsius#1945</string>
|
||||
<string name="incorrect_answers">New York City%Paris%Madrid#5%6%9%64#Read Admin Memory%Rapid Access Memory#0 degrees celsius%20 degrees celsius#2001%1666%1920</string>
|
||||
<string name="title_activity_notes">NotesActivity</string>
|
||||
<!-- Notes View -->
|
||||
<string name="addButtonText">Add</string>
|
||||
<string name="editButtonText">Edit</string>
|
||||
<string name="deleteButtonText">Delete</string>
|
||||
<string name="note_edit_hint">Notes</string>
|
||||
<string name="note_edit_hint">Note</string>
|
||||
<string name="saveButtonText">Save</string>
|
||||
<string name="quiz_button_text">Quiz</string>
|
||||
<string name="submit_button_text">Submit</string>
|
||||
<string name="dice_hint">How many sides do you want the dice to have?</string>
|
||||
<string name="dice_button_text">Roll</string>
|
||||
<string name="dice_roller_button_text">Dice Roller</string>
|
||||
<string name="change_background_button_text">Change Background</string>
|
||||
</resources>
|
||||
|
|
@ -19,4 +19,8 @@
|
|||
</style>
|
||||
<style name="Theme.CpsAssist.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="Theme.CpsAssist.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
<style name="edit_dialog">
|
||||
<item name="android:background">@color/black</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue