second
This commit is contained in:
parent
9e538771fb
commit
947655051c
@ -3,6 +3,13 @@
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="..\:/Android Projects/TaskListA2/app/src/main/res/layout/fragment_change_pass.xml" value="0.20520833333333333" />
|
||||
<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/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" />
|
||||
<entry key="..\:/AndroidStudio/TaskListA/app/src/main/res/drawable/bordershape.xml" value="0.22135416666666666" />
|
||||
<entry key="..\:/AndroidStudio/TaskListA/app/src/main/res/layout/activity_login_page.xml" value="0.20520833333333333" />
|
||||
<entry key="..\:/AndroidStudio/TaskListA/app/src/main/res/layout/fragment_activity_login_page.xml" value="0.2682291666666667" />
|
||||
|
@ -1,13 +1,20 @@
|
||||
package com.example.tasklist
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.DataBindingUtil.setContentView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.tasklist.databinding.FragmentChangePassBinding
|
||||
import android.content.SharedPreferences
|
||||
import android.net.wifi.WifiEnterpriseConfig
|
||||
import android.widget.Toast
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@ -24,6 +31,9 @@ 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(
|
||||
@ -41,8 +51,46 @@ class ChangePass : Fragment(){
|
||||
}
|
||||
|
||||
fun goToList() {
|
||||
findNavController().navigate(R.id.action_changePass_to_taskListFragment)
|
||||
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
|
||||
if(binding.passwordOld.text.toString().equals(sharedPreference.getString("STRING_KEY", null),true)) {
|
||||
if ((binding.passwordNew.text.toString()).length >= 4){
|
||||
savePass()
|
||||
Toast.makeText(requireActivity(),"Password updated!",Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_changePass_to_taskListFragment)
|
||||
}
|
||||
else{
|
||||
Toast.makeText(requireActivity(),"Password too short,it should have at least 4 characters!",Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_changePass_self)
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
Toast.makeText(requireActivity(),"Password is incorrect, try again!",Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_changePass_self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun savePass(){
|
||||
val insertedText = binding.passwordNew.text.toString()
|
||||
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
val editor = sharedPreference.edit()
|
||||
editor.apply{
|
||||
putString("STRING_KEY",insertedText)
|
||||
}.apply()
|
||||
}
|
||||
|
||||
|
||||
private fun loadData(){
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
val savedString = sharedPreference.getString("STRING_KEY", null)
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -9,6 +10,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.tasklist.databinding.FragmentLoginPageBinding
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import java.util.*
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
@ -43,13 +45,31 @@ class LoginPage : Fragment(){
|
||||
}
|
||||
|
||||
fun goToList() {
|
||||
if(binding.password.text.toString().equals("pass",true)){
|
||||
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
|
||||
if(binding.password.text.toString().equals(sharedPreference.getString("STRING_KEY", null),true)){
|
||||
savePass()
|
||||
findNavController().navigate(R.id.action_loginPage_to_taskListFragment)
|
||||
}
|
||||
else{
|
||||
Toast.makeText(requireActivity(),"Your password is incorrect. Try again!",Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_loginPage_self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun savePass(){
|
||||
val insertedText = binding.password.text.toString()
|
||||
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
val editor = sharedPreference.edit()
|
||||
editor.apply{
|
||||
putString("STRING_KEY",insertedText)
|
||||
}.apply()
|
||||
//Toast.makeText(requireActivity(),"Password updated",Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.NavController
|
||||
@ -7,6 +8,7 @@ import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var navController : NavController
|
||||
@ -16,10 +18,12 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
setContentView(R.layout.main_activity)
|
||||
|
||||
|
||||
val navView: BottomNavigationView = findViewById(R.id.bottom_navigation)
|
||||
navController = findNavController(R.id.nav_host_fragment)
|
||||
navView.setupWithNavController(navController)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -18,6 +18,5 @@ class MainApplication : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
val context: Context = MainApplication.applicationContext()
|
||||
}
|
||||
}
|
67
app/src/main/java/com/example/tasklist/SetPass.kt
Normal file
67
app/src/main/java/com/example/tasklist/SetPass.kt
Normal file
@ -0,0 +1,67 @@
|
||||
package com.example.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.tasklist.databinding.FragmentSetPassBinding
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private const val ARG_PARAM1 = "param1"
|
||||
private const val ARG_PARAM2 = "param2"
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
* Use the [SetPass.newInstance] factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
class SetPass : Fragment() {
|
||||
private lateinit var binding: FragmentSetPassBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
|
||||
binding = DataBindingUtil.inflate(
|
||||
inflater, R.layout.fragment_set_pass, container, false
|
||||
)
|
||||
|
||||
|
||||
binding.setpass = this@SetPass
|
||||
return binding.root
|
||||
}
|
||||
|
||||
fun goToList() {
|
||||
if ((binding.password.text.toString()).length >= 4) {
|
||||
savePass()
|
||||
Toast.makeText(requireActivity(), "Password is set", Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_setPass_to_taskListFragment)
|
||||
} else {
|
||||
Toast.makeText(requireActivity(),"Password too short,it should have at least 4 characters!",Toast.LENGTH_SHORT).show()
|
||||
findNavController().navigate(R.id.action_setPass_self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun savePass() {
|
||||
val insertedText = binding.password.text.toString()
|
||||
|
||||
val sharedPreference =
|
||||
requireActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE)
|
||||
val editor = sharedPreference.edit()
|
||||
editor.apply {
|
||||
putString("STRING_KEY", insertedText)
|
||||
}.apply()
|
||||
}
|
||||
}
|
@ -94,9 +94,9 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:onClick="@{() -> change.goToList()}"
|
||||
android:background="@drawable/buttonshape"
|
||||
android:drawableStart="@drawable/ic_touch_app_white_24dp"
|
||||
android:onClick="@{() -> change.goToList()}"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/change_password"
|
||||
|
96
app/src/main/res/layout/fragment_set_pass.xml
Normal file
96
app/src/main/res/layout/fragment_set_pass.xml
Normal file
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="setpass"
|
||||
type="com.example.tasklist.SetPass" />
|
||||
</data>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="63dp"
|
||||
android:elevation="0dp"
|
||||
app:cardCornerRadius="4dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/signin_signup_txt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/you_need_to_set_up_the_password"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#000000"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:drawableStart="@drawable/ic_lock_light_blue_24dp"
|
||||
android:drawablePadding="16dp"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="SpeakableTextPresentCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/signin_signup_btn"
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@drawable/buttonshape"
|
||||
android:drawableStart="@drawable/ic_touch_app_white_24dp"
|
||||
android:onClick="@{() -> setpass.goToList()}"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/set_the_password"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#fff"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</layout>
|
@ -49,5 +49,20 @@
|
||||
<action
|
||||
android:id="@+id/action_changePass_to_taskListFragment"
|
||||
app:destination="@id/taskListFragment" />
|
||||
<action
|
||||
android:id="@+id/action_changePass_self"
|
||||
app:destination="@id/changePass" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/setPass"
|
||||
android:name="com.example.tasklist.SetPass"
|
||||
android:label="fragment_set_pass"
|
||||
tools:layout="@layout/fragment_set_pass" >
|
||||
<action
|
||||
android:id="@+id/action_setPass_to_taskListFragment"
|
||||
app:destination="@id/taskListFragment" />
|
||||
<action
|
||||
android:id="@+id/action_setPass_self"
|
||||
app:destination="@id/setPass" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -22,4 +22,6 @@
|
||||
<string name="change_password">Change Password</string>
|
||||
<string name="change_the_password">Change the password</string>
|
||||
<string name="type_the_note">Type the note</string>
|
||||
<string name="set_the_password">Set the password</string>
|
||||
<string name="you_need_to_set_up_the_password">You need to set up the password!</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user