This commit is contained in:
s452641 2021-11-21 14:21:57 +01:00
parent 947655051c
commit 4789c4a405
8 changed files with 22 additions and 8 deletions

View File

@ -7,6 +7,7 @@
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/fragment_login_page.xml" value="0.20520833333333333" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/fragment_set_pass.xml" value="0.25" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/fragment_task_list.xml" value="0.20520833333333333" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/fragment_vahne_the_pass.xml" value="0.36666666666666664" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/item_task.xml" value="0.20520833333333333" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/main_activity.xml" value="0.20520833333333333" />
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/main_fragment.xml" value="0.20520833333333333" />

View File

@ -50,7 +50,7 @@ class Adding_tasks : Fragment() {
val textTask = binding.editTextName.text.toString()
val dateTask = simpleDateFormat.format(Date())
if (textTask != "" && dateTask != "") {
if (textTask != "") {
val ttask = Task(textTask, dateTask)
Database.taskDao.addTask(ttask)
}

View File

@ -31,9 +31,6 @@ class ChangePass : Fragment(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val sharedPreference =
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
Toast.makeText(requireActivity(),sharedPreference.getString("STRING_KEY", null),Toast.LENGTH_LONG).show()
}
override fun onCreateView(
@ -55,7 +52,7 @@ class ChangePass : Fragment(){
val sharedPreference =
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
if(binding.passwordOld.text.toString().equals(sharedPreference.getString("STRING_KEY", null),true)) {
if(binding.passwordOld.text.toString().equals(sharedPreference.getString("STRING_KEY", null),false)) {
if ((binding.passwordNew.text.toString()).length >= 4){
savePass()
Toast.makeText(requireActivity(),"Password updated!",Toast.LENGTH_SHORT).show()

View File

@ -28,9 +28,11 @@ class LoginPage : Fragment(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
@ -39,6 +41,7 @@ class LoginPage : Fragment(){
inflater, R.layout.fragment_login_page, container, false
)
checkIfPassSet()
binding.login = this@LoginPage
return binding.root
@ -49,7 +52,7 @@ class LoginPage : Fragment(){
val sharedPreference =
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
if(binding.password.text.toString().equals(sharedPreference.getString("STRING_KEY", null),true)){
if(binding.password.text.toString().equals(sharedPreference.getString("STRING_KEY", null),false)){
savePass()
findNavController().navigate(R.id.action_loginPage_to_taskListFragment)
}
@ -69,7 +72,14 @@ class LoginPage : Fragment(){
editor.apply{
putString("STRING_KEY",insertedText)
}.apply()
//Toast.makeText(requireActivity(),"Password updated",Toast.LENGTH_SHORT).show()
}
private fun checkIfPassSet(){
val sharedPreference =
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
if(sharedPreference.getString("STRING_KEY", null) == null){
findNavController().navigate(R.id.action_loginPage_to_setPass)
}
}
}

View File

@ -64,4 +64,6 @@ class SetPass : Fragment() {
putString("STRING_KEY", insertedText)
}.apply()
}
}

View File

@ -9,6 +9,8 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
class TaskDao {
fun getAllTasks() : ArrayList<Task> {
return DataSource.zadanie
}

View File

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="fragment"
type="com.example.tasklist.Adding_tasks" />

View File

@ -40,6 +40,9 @@
<action
android:id="@+id/action_loginPage_self"
app:destination="@id/loginPage" />
<action
android:id="@+id/action_loginPage_to_setPass"
app:destination="@id/setPass" />
</fragment>
<fragment
android:id="@+id/changePass"