diff --git a/.idea/misc.xml b/.idea/misc.xml index 480c79e..69dab29 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -16,6 +16,11 @@ + + + + + diff --git a/app/src/main/java/com/example/tasklist/Adding_tasks.kt b/app/src/main/java/com/example/tasklist/Adding_tasks.kt index d9d3baf..f300acf 100644 --- a/app/src/main/java/com/example/tasklist/Adding_tasks.kt +++ b/app/src/main/java/com/example/tasklist/Adding_tasks.kt @@ -5,10 +5,12 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Toast import androidx.annotation.RequiresApi import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController +import com.example.tasklist.data.DataSource import com.example.tasklist.data.Database import com.example.tasklist.data.Task import com.example.tasklist.databinding.FragmentAddingTasksBinding diff --git a/app/src/main/java/com/example/tasklist/data/Task.kt b/app/src/main/java/com/example/tasklist/data/Task.kt index 3e6c6ee..bc9ac22 100644 --- a/app/src/main/java/com/example/tasklist/data/Task.kt +++ b/app/src/main/java/com/example/tasklist/data/Task.kt @@ -3,4 +3,5 @@ package com.example.tasklist.data data class Task( var name: String, var date: String + ) \ No newline at end of file diff --git a/app/src/main/java/com/example/tasklist/data/dao/TaskDao.kt b/app/src/main/java/com/example/tasklist/data/dao/TaskDao.kt index 926c881..3725c4e 100644 --- a/app/src/main/java/com/example/tasklist/data/dao/TaskDao.kt +++ b/app/src/main/java/com/example/tasklist/data/dao/TaskDao.kt @@ -52,7 +52,7 @@ class TaskDao { DataSource.zadanie.addAll(readedData) } - private fun loadListFromSharedPreferneces( + fun loadListFromSharedPreferneces( context: Context, sharedPreferencesTag: String ): List { diff --git a/app/src/main/java/com/example/tasklist/itemOnDis.kt b/app/src/main/java/com/example/tasklist/itemOnDis.kt deleted file mode 100644 index aa6dece..0000000 --- a/app/src/main/java/com/example/tasklist/itemOnDis.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.tasklist - -import android.os.Build -import androidx.annotation.RequiresApi - -class itemOnDis { - @RequiresApi(Build.VERSION_CODES.O) - fun encryptedToStr(str:String):String{ - val crypting = ChCrypto - val taskCrypred = crypting.aesDecrypt(str) - return taskCrypred - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/tasklist/ui/choose/list/TaskListFragment.kt b/app/src/main/java/com/example/tasklist/ui/choose/list/TaskListFragment.kt index aeaa59b..1eb0a8b 100644 --- a/app/src/main/java/com/example/tasklist/ui/choose/list/TaskListFragment.kt +++ b/app/src/main/java/com/example/tasklist/ui/choose/list/TaskListFragment.kt @@ -1,20 +1,26 @@ package com.example.tasklist.ui.choose.list import android.annotation.SuppressLint +import android.content.Context +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.annotation.RequiresApi import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController +import com.example.tasklist.ChCrypto +import com.example.tasklist.MainApplication import com.example.tasklist.R import com.example.tasklist.data.DataSource import com.example.tasklist.data.Database import com.example.tasklist.data.Repository import com.example.tasklist.data.Task +import com.example.tasklist.data.dao.TaskDao import com.example.tasklist.databinding.FragmentTaskListBinding import com.example.tasklist.ui.adapters.TaskAdapter import com.example.tasklist.ui.adapters.TaskItemClickListener @@ -30,9 +36,12 @@ class TaskListFragment : Fragment(), TaskItemClickListener { val sharedViewModel : TaskListViewModel by activityViewModels() override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + } + @RequiresApi(Build.VERSION_CODES.O) override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -45,7 +54,6 @@ class TaskListFragment : Fragment(), TaskItemClickListener { mAdapter.submitList(Repository.getAllTasks().value) binding.recyclerView.adapter = mAdapter binding.fragment = this@TaskListFragment - subscribeUi(mAdapter, binding) return binding.root @@ -56,9 +64,23 @@ class TaskListFragment : Fragment(), TaskItemClickListener { newAdapter.notifyDataSetChanged() } + @RequiresApi(Build.VERSION_CODES.O) override fun chooseTask(task: Task) { - val taskToast = Toast.makeText(activity, "Zostało wybrane zadanie ${task.name}", Toast.LENGTH_LONG) + val crypting = ChCrypto + val taskCrypred = crypting.aesDecrypt(task.name) + val taskToast = Toast.makeText(activity, "Zostało wybrane zadanie $taskCrypred", Toast.LENGTH_LONG) taskToast.show() + // val taskToast = Toast.makeText(activity, "Zostało wybrane zadanie ${task.name}", Toast.LENGTH_LONG) + } + + @SuppressLint("ShowToast") + @RequiresApi(Build.VERSION_CODES.O) + fun decryptTasks(task: Task): String { + val crypting = ChCrypto + val taskDeCrypred = crypting.aesDecrypt(task.name) + val taskToast = Toast.makeText(activity,taskDeCrypred, Toast.LENGTH_LONG) + taskToast.show() + return taskDeCrypred } fun addTask(){ diff --git a/app/src/main/res/layout/item_task.xml b/app/src/main/res/layout/item_task.xml index 569387a..36bb166 100644 --- a/app/src/main/res/layout/item_task.xml +++ b/app/src/main/res/layout/item_task.xml @@ -13,6 +13,10 @@ + + @@ -26,7 +30,7 @@ android:id="@+id/checkBox_task" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text='@{task.name + "\n" + task.date}' + android:text='@{tlf.decryptTasks(task) + "\n" + task.date}' android:onClick="@{() -> clickListener.chooseTask(task)}" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent"