-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Minime998/daily_quests
- Loading branch information
Showing
24 changed files
with
620 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
app/src/main/java/com/example/camlingo/AudioQuestionFragment.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/src/main/java/com/example/camlingo/LessonRecyclerViewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
53
app/src/main/java/com/example/camlingo/LessonsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.