Skip to content

Commit

Permalink
Merge pull request #30 from Minime998/daily_quests
Browse files Browse the repository at this point in the history
  • Loading branch information
Minime998 authored Dec 2, 2024
2 parents ddb4515 + c12bda4 commit d8f4d00
Show file tree
Hide file tree
Showing 24 changed files with 620 additions and 310 deletions.
11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:theme="@style/Theme.Material3.Light">

<uses-permission android:name="android.permission.CAMERA" />
<!-- <uses-permission android:name="android.permission.CAMERA" />-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -16,6 +17,12 @@
android:supportsRtl="true"
android:theme="@style/Base.Theme.CamLingo"
tools:targetApi="31">
<activity
android:name=".LessonRecyclerViewActivity"
android:exported="false" />
<activity
android:name=".LessonsActivity"
android:exported="false" />
<activity
android:name=".MyLeaningActivity"
android:exported="false" />
Expand Down
23 changes: 0 additions & 23 deletions app/src/main/java/com/example/camlingo/AudioQuestionFragment.java

This file was deleted.

27 changes: 4 additions & 23 deletions app/src/main/java/com/example/camlingo/DailyQuestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,59 @@

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.bumptech.glide.Glide;

import java.io.File;
import java.io.FileInputStream;
import java.util.Objects;

import model.MultipleChoiceQuestion;
import repository.QuestionRepository;

public class DailyQuestActivity extends AppCompatActivity {
private static final String TAG = "DailyQuestActivity";
private Button ClaimButton, StarQuestButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_daily_quest);

Bitmap iconImg;

//find button by id
ClaimButton = findViewById(R.id.claim_button_DailyQuest);
StarQuestButton = findViewById(R.id.startQuest_button_DailyQuest);
Button claimButton = findViewById(R.id.claim_button_DailyQuest);
Button starQuestButton = findViewById(R.id.startQuest_button_DailyQuest);
ImageView treasureChest = findViewById(R.id.questHomeIcon);

Glide.with(treasureChest)
.load("https://firebasestorage.googleapis.com/v0/b/camlingo-app.firebasestorage.app/o/treasure-chest.png?alt=media&token=f2781c98-a752-49b4-836d-ca80e64fea52")
.into(treasureChest);



//"Claim Now" button click
ClaimButton.setOnClickListener(new View.OnClickListener() {
claimButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//no activity to open yet, just a placeholder here
//Intent intent = new Intent(DailyQuestActivity.this, DailyQuestActivity.class);
//startActivity(intent);
Toast.makeText(DailyQuestActivity.this, "ClaimButton Clicked", Toast.LENGTH_SHORT).show();

}
});

//Start today's quest button click
StarQuestButton.setOnClickListener(new View.OnClickListener() {
starQuestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DailyQuestActivity.this, DailyQuestsTasks.class);
startActivity(intent);
Toast.makeText(DailyQuestActivity.this, "StarQuestButton Clicked", Toast.LENGTH_SHORT).show();

}
});


ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.daily_quests), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.example.camlingo;

import android.os.Bundle;
import android.util.Log;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QueryDocumentSnapshot;

import java.util.ArrayList;

import model.LessonModel;

public class LessonRecyclerViewActivity extends AppCompatActivity {
ArrayList<LessonModel> lessonModels = new ArrayList<>();
private RecyclerViewAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_lesson_recycler_view);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});

String lessonType = getIntent().getStringExtra("lessonType");
if (lessonType != null){
fetchLessonData(lessonType);
Log.i("RecyclerView", "lessonType: " + lessonType);
}

RecyclerView recyclerView = findViewById(R.id.lessonRecycleView);

adapter = new RecyclerViewAdapter(this, lessonModels);

recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}

private void fetchLessonData( String lessonType){
FirebaseFirestore db = FirebaseFirestore.getInstance("camlingo");
lessonType.toLowerCase();

// Dynamically construct Firestore path
String subCollection = "english_" + lessonType;
String documentName = "learn_"+ lessonType;

Log.i("RecyclerView", "doc:" + documentName + ",subsect: " + subCollection);

db.collection("lessons")
.document(documentName)
.collection(subCollection)
.get()
.addOnSuccessListener(queryDocumentSnapshots -> {
for (QueryDocumentSnapshot document : queryDocumentSnapshots){
String itemText = document.getString("text");
String phrase = document.getString("phrase");
String media = document.getString("mediaUrl");
String itemId = document.getId();
LessonModel lessonModelItem = new LessonModel(itemText,phrase,media,itemId);
lessonModels.add(lessonModelItem);
Log.i("RecyclerView", "verb found: " + itemText);
}
adapter.notifyDataSetChanged();
})
.addOnFailureListener(e -> {
System.err.println("Error fetching lesson data: " + e.getMessage());
});
}

}
53 changes: 53 additions & 0 deletions app/src/main/java/com/example/camlingo/LessonsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.example.camlingo;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;

public class LessonsActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_lessons);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.lesson_activity_layout), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});

// setup views
Button verbs_lesson_btn = findViewById(R.id.verbs_lesson_btn);
Button nouns_lesson_btn = findViewById(R.id.nouns_lesson_btn);
Button vocab_lesson_btn = findViewById(R.id.vocab_lesson_btn);
Button prepos_lesson_btn = findViewById(R.id.prepos_lesson_btn);
Button adj_lesson_btn = findViewById(R.id.adj_lesson_btn);

ArrayList<Button> lessonButtons = new ArrayList<>();
lessonButtons.add(verbs_lesson_btn);
lessonButtons.add(nouns_lesson_btn);
lessonButtons.add(vocab_lesson_btn);
lessonButtons.add(prepos_lesson_btn);
lessonButtons.add(adj_lesson_btn);

for (Button button : lessonButtons){
button.setOnClickListener(v -> {
String lessonType = button.getText().toString().toLowerCase();
Intent intent = new Intent(this, LessonRecyclerViewActivity.class);
intent.putExtra("lessonType", lessonType);
startActivity(intent);
});
}

}
}
14 changes: 13 additions & 1 deletion app/src/main/java/com/example/camlingo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
package com.example.camlingo;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.cardview.widget.CardView;

import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QueryDocumentSnapshot;

import java.util.List;
import java.util.Objects;

import database.AppDatabaseHelper;
import database.FireBaseQuestionLoader;
import model.LessonModel;
import model.MultipleChoiceQuestion;
import utils.AppUser;

public class MainActivity extends AppCompatActivity {
Expand All @@ -25,6 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// Find CardViews by ID
CardView myLearningCard = findViewById(R.id.continue_learning_card);
CardView dailyQuestsCard = findViewById(R.id.daily_quests_card);
Expand Down Expand Up @@ -54,6 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
FireBaseQuestionLoader qloader = new FireBaseQuestionLoader(this);
qloader.loadQuestions();


// Set up the toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand All @@ -79,7 +92,6 @@ protected void onCreate(Bundle savedInstanceState) {
//Intent intent = new Intent(MainActivity.this, MainActivity.class);
//startActivity(intent);
Toast.makeText(MainActivity.this, "leaderboardCard Clicked", Toast.LENGTH_SHORT).show();

});

}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/example/camlingo/MyLeaningActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ protected void onCreate(Bundle savedInstanceState) {
.load(R.drawable.backpack)
.into(animated_bag);

// Click on english basics card
english_basics_card.setOnClickListener(v ->{
startActivity(new Intent(MyLeaningActivity.this, LessonsActivity.class));
});

// Click on picture learning
picture_learning_card.setOnClickListener(v -> {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/example/camlingo/QuestionFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class QuestionFragment extends Fragment {
private Button checkBtn;
private Button continueBtn;
private Button finishBtn;
private Button playAudioButton;
private ProgressBar progressBar;
private RadioButton option1, option2, option3, option4;
private RadioGroup optionsGroup;
Expand Down Expand Up @@ -69,7 +68,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
checkBtn = view.findViewById(R.id.checkBtn);
progressBar = view.findViewById(R.id.progressBar);
continueBtn = view.findViewById(R.id.continueBtn);
playAudioButton = view.findViewById(R.id.playAudioButton);
questionText = view.findViewById(R.id.img_question_text);
scoreText = view.findViewById(R.id.scoreText);
questionImage = view.findViewById(R.id.question_img);
Expand Down
Loading

0 comments on commit d8f4d00

Please sign in to comment.