Skip to content

Commit

Permalink
Added audio hints, fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreihar committed Jun 10, 2022
1 parent 0e80319 commit 82432f5
Show file tree
Hide file tree
Showing 19 changed files with 266 additions and 172 deletions.
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

187 changes: 148 additions & 39 deletions app/src/main/java/com/example/firstapp/FirstFragment.java

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions app/src/main/java/com/example/firstapp/MainMenuFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.example.firstapp;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;

import com.example.firstapp.databinding.FragmentMainMenuBinding;

import java.util.Random;

public class MainMenuFragment extends Fragment {

private FragmentMainMenuBinding binding;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentMainMenuBinding.inflate(inflater, container, false);
return binding.getRoot();
}

public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

view.findViewById(R.id.quiz_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NavHostFragment.findNavController(MainMenuFragment.this)
.navigate(R.id.action_MainMenuFragment_to_FirstFragment);
}
});
}

@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}

}
11 changes: 7 additions & 4 deletions app/src/main/java/com/example/firstapp/Question.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.example.firstapp;

import java.io.File;

public class Question {
private String question, first, second, third, fourth, answer, hint;
private String question, first, second, third, fourth, answer;
private int hint;

// Constructor
public Question(String question, String first, String second, String third, String fourth, String answer, String hint) {
public Question(String question, String first, String second, String third, String fourth, String answer, int hint) {
this.question = question;
this.first = first;
this.second = second;
Expand Down Expand Up @@ -63,11 +66,11 @@ public void setAnswer(String answer) {
this.answer = answer;
}

public String getHint() {
public int getHint() {
return hint;
}

public void setHint(String hint) {
public void setHint(int hint) {
this.hint = hint;
}
}
56 changes: 0 additions & 56 deletions app/src/main/java/com/example/firstapp/SecondFragment.java

This file was deleted.

11 changes: 11 additions & 0 deletions app/src/main/res/layout/fragment_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,15 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/back_to_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/question" />

</androidx.constraintlayout.widget.ConstraintLayout>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/fragment_main_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/screenBackground2"
tools:context=".MainMenuFragment">

<Button
android:id="@+id/quiz_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/start_quiz"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
48 changes: 0 additions & 48 deletions app/src/main/res/layout/fragment_second.xml

This file was deleted.

14 changes: 7 additions & 7 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/FirstFragment">
app:startDestination="@id/SecondFragment">

<fragment
android:id="@+id/FirstFragment"
android:name="com.example.firstapp.FirstFragment"
android:label="@string/first_fragment_label"
android:label="@string/quiz_label"
tools:layout="@layout/fragment_first" >

<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
android:id="@+id/action_FirstFragment_to_MainMenuFragment"
app:destination="@id/SecondFragment" />
</fragment>
<fragment
android:id="@+id/SecondFragment"
android:name="com.example.firstapp.SecondFragment"
android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second" >
android:name="com.example.firstapp.MainMenuFragment"
android:label="@string/main_menu_fragment_label"
tools:layout="@layout/fragment_main_menu" >

<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
android:id="@+id/action_MainMenuFragment_to_FirstFragment"
app:destination="@id/FirstFragment" />
<argument
android:name="myArg"
Expand Down
Binary file added app/src/main/res/raw/hint1.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/hint2.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/hint3.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/hint4.mp3
Binary file not shown.
Binary file added app/src/main/res/raw/hint5.mp3
Binary file not shown.
13 changes: 7 additions & 6 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">首个应用</string>
<string name="app_name">内存通道</string>
<string name="action_settings">设置</string>
<string name="first_fragment_label">第一个片段</string>
<string name="second_fragment_label">第二个片段</string>
<string name="previous">以前的</string>
<string name="quiz_label">测验</string>
<string name="main_menu_fragment_label">主菜单</string>
<string name="hello_first_fragment">0</string>
<string name="random_heading">这是一个介于 0 和</string>
<string name="first_choice_text">第一</string>
<string name="second_choice_text">第二</string>
<string name="third_choice_text">第三</string>
<string name="fourth_choice_text">第四</string>
<string name="answered_correctly">%1$d</string>
<string name="answered_all_questions">回答了所有问题</string>
<string name="answered_all_questions">您回答了所有问题</string>
<string name="loading">加载请稍候</string>
<string name="start_quiz">开始测验</string>
<string name="back_to_menu">返回菜单</string>
</resources>
13 changes: 7 additions & 6 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">首個應用</string>
<string name="app_name">內存通道</string>
<string name="action_settings">設置</string>
<string name="first_fragment_label">第一個片段</string>
<string name="second_fragment_label">第二個片段</string>
<string name="previous">以前的</string>
<string name="quiz_label">測驗</string>
<string name="main_menu_fragment_label">主菜單</string>
<string name="hello_first_fragment">0</string>
<string name="random_heading">這是一個介於 0 和</string>
<string name="first_choice_text">第一</string>
<string name="second_choice_text">第二</string>
<string name="third_choice_text">第三</string>
<string name="fourth_choice_text">第四</string>
<string name="answered_correctly">%1$d</string>
<string name="answered_all_questions">回答了所有問題</string>
<string name="answered_all_questions">您回答了所有問題</string>
<string name="loading">加載請稍候</string>
<string name="start_quiz">開始測驗</string>
<string name="back_to_menu">返回菜單</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<color name="screenBackground">#2196F3</color>
<color name="buttonBackground">#BBDEFB</color>
<color name="screenBackground2">#26C6DA</color>
<color name="highlight_button">#E60C0C</color>
</resources>
12 changes: 6 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<resources>
<string name="app_name">FirstApp</string>
<string name="app_name">Memory Lane</string>
<string name="action_settings">Settings</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">First Fragment</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="previous">Previous</string>

<string name="quiz_label">Quiz</string>
<string name="main_menu_fragment_label">Main Menu</string>
<string name="hello_first_fragment">0</string>
<string name="random_heading">Here is a random number between 0 and %d.</string>
<string name="first_choice_text">First</string>
<string name="second_choice_text">Second</string>
<string name="third_choice_text">Third</string>
<string name="fourth_choice_text">Fourth</string>
<string name="answered_correctly">%1$d</string>
<string name="answered_all_questions">Answered all questions</string>
<string name="loading">Loading... Please Wait</string>
<string name="back_to_menu">Back to Menu</string>
<string name="start_quiz">Start Quiz</string>
</resources>

0 comments on commit 82432f5

Please sign in to comment.