parent
7a0acc9a2b
commit
0a828ef8a0
@ -0,0 +1,11 @@
|
||||
package fr.uca.iut.clfreville2.teaiswarm.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import fr.uca.iut.clfreville2.teaiswarm.R
|
||||
|
||||
class PreferencesFragment : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) =
|
||||
setPreferencesFromResource(R.xml.preferences, rootKey)
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package fr.uca.iut.clfreville2.teaiswarm.fragment
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import androidx.core.content.edit
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.findNavController
|
||||
import fr.uca.iut.clfreville2.teaiswarm.R
|
||||
import fr.uca.iut.clfreville2.teaiswarm.USERNAME
|
||||
|
||||
class SetupConfigFragment(private val preferences: SharedPreferences) : Fragment(R.layout.setup_config) {
|
||||
|
||||
private lateinit var usernameInput: EditText
|
||||
private lateinit var confirmButton: Button
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
usernameInput = view.findViewById(R.id.username_input)
|
||||
confirmButton = view.findViewById(R.id.configure_button)
|
||||
confirmButton.setOnClickListener {
|
||||
preferences.edit {
|
||||
putString(USERNAME, usernameInput.text.toString())
|
||||
}
|
||||
view.findNavController().navigate(R.id.repository_list_fragment)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/configure_button"
|
||||
android:autofillHints="" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/configure_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/configure"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<EditTextPreference
|
||||
app:key="username"
|
||||
app:title="@string/username" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in new issue