Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ dependencies {

// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation 'com.google.android.material:material:1.9.0'

}
74 changes: 0 additions & 74 deletions app/src/debug/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
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>
15 changes: 0 additions & 15 deletions app/src/debug/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108"
android:tint="#000000">
<group android:scaleX="2.61"
android:scaleY="2.61"
android:translateX="22.68"
android:translateY="22.68">
<path
android:fillColor="@android:color/white"
android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</group>
</vector>
15 changes: 9 additions & 6 deletions app/src/debug/res/drawable/rounded_cardview.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#2196f3" />
<gradient
android:type="linear"
android:startColor="#9575cd"
android:endColor="#b39ddb"
android:angle="90" />

<corners
android:topLeftRadius="65dp"
android:topRightRadius="65dp"
android:bottomLeftRadius="65dp"
android:bottomRightRadius="65dp" />
android:topLeftRadius="45dp"
android:topRightRadius="45dp"
android:bottomLeftRadius="45dp"
android:bottomRightRadius="45dp" />
</shape>
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

<application
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:name=".MyApp"
android:supportsRtl="true"

android:theme="@style/Theme.AppCompat.Light.NoActionBar"

tools:targetApi="31">
Expand Down
72 changes: 40 additions & 32 deletions app/src/main/java/com/example/visuallithuanian/QuestionsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ package com.example.visuallithuanian

import android.animation.*
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.Navigation
import androidx.navigation.fragment.findNavController
import com.example.visuallithuanian.database.FlashcardPair
import com.example.visuallithuanian.databinding.FragmentQuestionsBinding
Expand All @@ -30,19 +26,19 @@ import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class QuestionsFragment : Fragment() {
lateinit var binding: FragmentQuestionsBinding
lateinit var binding:FragmentQuestionsBinding
lateinit var viewModel: BottomNavigationViewModel

lateinit var bottomNavigationView: BottomNavigationView
private val counterViewModel: ToLearnViewModel by viewModels()

private val hashMap = HashMap<String,String>()
private val hashMap = HashMap<String,Pair<String,Int>>()

private var currentPairIndex =0
private lateinit var currentPair:Map.Entry<String,String>
private lateinit var currentPair:Map.Entry<String,Pair<String,Int>>

var isFront=true
private val totalPairs = 17 // change the value to the actual number of entries in your hashMap
private val totalPairs = 16 // change the value to the actual number of entries in your hashMap

// declaring viewmodel
private val cardViewModel: FlashCardViewmodel by viewModels {
Expand Down Expand Up @@ -81,23 +77,24 @@ class QuestionsFragment : Fragment() {
R.color.silver))

// Hashmap of strings that will shown on cardview front and back side
hashMap["What"] = "Kas"
hashMap["When"] = "Kai"
hashMap["Where"] = "Kur"
hashMap["Who"] = "Kas"
hashMap["Whom"] = "Kam"
hashMap["Why"] = "Kodėl"
hashMap["How"] = "Kaip"
hashMap["Which"] = "Kuris/kuri"
hashMap["Whose"] = "Kieno"
hashMap["I"] = "aš"
hashMap["you (singular)"] = "tu/jūs (informal/formal)"
hashMap["he"] = "jis"
hashMap["she"] = "ji"
hashMap["it "] = "tai"
hashMap["we"] = "mes"
hashMap["you (plural)"] = "jūs"
hashMap["they"] = "jie"
hashMap["What"] = Pair("Kas", R.drawable.what)
hashMap["When"] = Pair("Kai",R.drawable.whennn)
hashMap["Where"] = Pair("Kur",R.drawable.where)
hashMap["Who"] = Pair("Kas",R.drawable.who)
hashMap["Whom"] = Pair("Kam",R.drawable.whom)
hashMap["Why"] = Pair("Kodėl",R.drawable.why)
hashMap["How"] = Pair("Kaip",R.drawable.how)
hashMap["Which"] = Pair("Kuris/kuri",R.drawable.which)
hashMap["Whose"] = Pair("Kieno",R.drawable.whose)
hashMap["I"] = Pair("aš",R.drawable.i)
hashMap["you (singular)"] = Pair("tu/jūs (informal/formal)",R.drawable.you)
hashMap["he"] = Pair("jis",R.drawable.he)
hashMap["she"] = Pair("ji",R.drawable.she)
hashMap["we"] = Pair("mes",R.drawable.we)
hashMap["you (plural)"] = Pair("jūs",R.drawable.you)
hashMap["they"] = Pair("jie",R.drawable.they)



counterViewModel.counter.observe(requireActivity()){count->
binding.textCounter.text = count.toString()
Expand All @@ -107,10 +104,13 @@ class QuestionsFragment : Fragment() {

currentPair = hashMap.entries.elementAt(currentPairIndex)
binding.textCardFront.text = currentPair.key
binding.textCardBack.text = hashMap[currentPair.key]
binding.textCardBack.text = currentPair.value.first
binding.imagecardsHelper.setImageResource(currentPair.value.second!!)

// onclick listener on the image
binding.imageFlashCard.setOnClickListener {
val clickedColor = ContextCompat.getColor(requireContext(), R.color.white)
binding.imageFlashCard.setBackgroundColor(clickedColor)

counterViewModel.incrementCounter()
// increment currentPairIndex and get the next pair
Expand All @@ -123,15 +123,19 @@ class QuestionsFragment : Fragment() {

val front = binding.textCardFront.text.toString()
val back = binding.textCardBack.text.toString()
val imageHelper = currentPair.value.second

val pair = FlashcardPair(front, back)
val pair = FlashcardPair(front, back,imageHelper!!)
cardViewModel.insertCards(pair)
Toast.makeText(requireContext(),"saved data", Toast.LENGTH_SHORT).show()
//Toast.makeText(requireContext(),"saved data", Toast.LENGTH_SHORT).show()
Log.d("Main","$pair")

// update the UI with the new pair
binding.textCardFront.text = currentPair.key
binding.textCardBack.text = hashMap[currentPair.key]
binding.textCardBack.text =currentPair.value.first
binding.imagecardsHelper.setImageResource(currentPair.value.second!!)



}

Expand All @@ -147,6 +151,9 @@ class QuestionsFragment : Fragment() {
val progress = ((currentPairIndex + 1) * 100) / totalPairs
binding.progressHorizontal.progress = progress

val originalColor = ContextCompat.getColor(requireContext(), R.color.pink)
binding.imageFlashCard.setBackgroundColor(originalColor)

// initialize currentPairIndex to 0 if it hasn't been initialized yet
if (currentPairIndex < 0) {
currentPairIndex = 0
Expand All @@ -160,14 +167,14 @@ class QuestionsFragment : Fragment() {
textCardBack.visibility = View.VISIBLE
textCardFront.visibility = View.GONE
imageFlashCard.visibility = View.GONE
cardViewQuestions.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.pink))
cardViewQuestions.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.card_purple))

} else {
currentPairIndex = (currentPairIndex + 1) % hashMap.size
textCardFront.visibility = View.VISIBLE
textCardBack.visibility = View.GONE
imageFlashCard.visibility = View.VISIBLE
cardViewQuestions.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.blue_card))
cardViewQuestions.setCardBackgroundColor(ContextCompat.getColor(requireContext(), R.color.pink))
front_animation.setTarget(textCardBack)
back_animation.setTarget(textCardFront)
back_animation.start()
Expand All @@ -184,7 +191,8 @@ class QuestionsFragment : Fragment() {
// retrieve the current pair from the hashMap
currentPair = hashMap.entries.elementAt(currentPairIndex)
binding.textCardFront.text = currentPair.key
binding.textCardBack.text = hashMap[currentPair.key]
binding.textCardBack.text = currentPair.value.first
binding.imagecardsHelper.setImageResource(currentPair.value.second!!)
}
}

Expand Down
38 changes: 27 additions & 11 deletions app/src/main/java/com/example/visuallithuanian/ToLearnFlashCards.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.example.visuallithuanian


import com.example.visuallithuanian.custom.OverlappingLayoutManager
import android.animation.ObjectAnimator
import android.graphics.Canvas
import android.os.Bundle
import android.view.GestureDetector
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.observe
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.example.visuallithuanian.adapter.FlashcardpaiAdapter
import com.example.visuallithuanian.custom.OverlappingLayoutManager
import com.example.visuallithuanian.database.FlashcardPair
import com.example.visuallithuanian.databinding.FragmentToLearnFlashCardsBinding
import com.example.visuallithuanian.ui.activities.FirstScreen
import com.example.visuallithuanian.viewModel.FlashCardViewmodel
Expand All @@ -34,22 +32,40 @@ class ToLearnFlashCards : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
// Inflate the layout for this fragment
binding = FragmentToLearnFlashCardsBinding.inflate(layoutInflater,container,false)

//Taking the bOTTOMNavigation view instance from Activity into Fragment
bottomNav = (activity as? FirstScreen)?.findViewById(R.id.bottomNavigationView)!!
bottomNav.visibility = View.VISIBLE

// Bounce animation for emojiBounce view
val bounceAnimator = ObjectAnimator.ofFloat(
binding.emojiBounce,
"translationX",
0f,
-100f,
0f
).apply {
duration = 2000 // Set the duration of the animation
repeatCount = ObjectAnimator.INFINITE // Set the repeat count for infinite bouncing
repeatMode = ObjectAnimator.REVERSE // Reverse the animation after each repeat
}

// Start the bounce animation
bounceAnimator.start()

binding.backIcon.setOnClickListener {
findNavController().navigate(R.id.action_toLearnFlashCards_to_flashCards)
}

val adapter = FlashcardpaiAdapter{cardPair->
cardViewmodel.deleteCards(cardPair)
val adapter = FlashcardpaiAdapter(
onDeleteListener = {cardPair->
cardViewmodel.insertCards(cardPair)
},
)

}
binding.recyclerview.adapter = adapter

//Swipe Gesture
Expand All @@ -73,11 +89,11 @@ class ToLearnFlashCards : Fragment() {
})
itemTouchHelper.attachToRecyclerView(binding.recyclerview)

binding.recyclerview.layoutManager = OverlappingLayoutManager()
binding.recyclerview.layoutManager = OverlappingLayoutManager(binding.root.context)
// binding.recyclerview.rotation=10f

//Observe the data changes for the items added
cardViewmodel.allWords.observe(requireActivity()) { cardPairs ->
cardViewmodel.allWords.observe(viewLifecycleOwner) { cardPairs ->

adapter.submitList(cardPairs)

Expand Down
Loading