Commit 946609c5 authored by m-spi's avatar m-spi

Enfin, une structure de page cohérente, et des boutons qui marchent (maybe)

parent a7b30035
...@@ -20,6 +20,7 @@ import androidx.fragment.app.Fragment ...@@ -20,6 +20,7 @@ import androidx.fragment.app.Fragment
import com.example.elbuenopeso.databinding.FragmentAddBinding import com.example.elbuenopeso.databinding.FragmentAddBinding
@Suppress("DEPRECATION")
class AddFragment : Fragment() { class AddFragment : Fragment() {
private var _binding: FragmentAddBinding? = null private var _binding: FragmentAddBinding? = null
...@@ -32,39 +33,24 @@ class AddFragment : Fragment() { ...@@ -32,39 +33,24 @@ class AddFragment : Fragment() {
lateinit var click_image_id: ImageView lateinit var click_image_id: ImageView
private val galleryActivityResultLauncher: ActivityResultLauncher<Intent> = private val galleryActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult(), registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
ActivityResultCallback { fun onActivityResult( result -> run {
requestCode: Int, if (result.resultCode == Activity.RESULT_OK) {
resultCode: Int, val image = result?.data?.data as Uri
data: Intent
) {
if (resultCode == Activity.RESULT_OK) {
val image = data.data as Uri
click_image_id.setImageURI(image) click_image_id.setImageURI(image)
} }
}} }
) }
private var cameraActivityResultLauncher: ActivityResultLauncher<Intent> = private val cameraActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult(), registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
ActivityResultCallback { result -> run {
fun onActivityResult( if (result.resultCode == Activity.RESULT_OK) {
requestCode: Int, val image = result.data?.extras?.get("data") as Bitmap?
resultCode: Int, click_image_id.setImageBitmap(image)
data: Intent
) {
Log.d("tag", "$resultCode")
if (resultCode == Activity.RESULT_OK) {
val image = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
data.extras?.getParcelable("data", Bitmap::class.java)
} else {
throw Exception("Oups, en fait c'est pas Android 14...")
}
camera_open_id.setImageBitmap(image)
binding.title.setText("aaa")
} }
}} }
) }
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
...@@ -87,7 +73,7 @@ class AddFragment : Fragment() { ...@@ -87,7 +73,7 @@ class AddFragment : Fragment() {
binding.cameraButton.setOnClickListener { binding.cameraButton.setOnClickListener {
val camera = Intent(MediaStore.ACTION_IMAGE_CAPTURE) val camera = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
galleryActivityResultLauncher.launch(camera) cameraActivityResultLauncher.launch(camera)
} }
// val textView: TextView = binding.textNotifications // val textView: TextView = binding.textNotifications
......
...@@ -7,6 +7,19 @@ ...@@ -7,6 +7,19 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"> android:paddingTop="?attr/actionBarSize">
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation"
tools:ignore="FragmentTagUsage" />
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view" android:id="@+id/nav_view"
android:layout_width="0dp" android:layout_width="0dp"
...@@ -19,17 +32,4 @@ ...@@ -19,17 +32,4 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" /> app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation"
tools:ignore="FragmentTagUsage" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -6,74 +6,92 @@ ...@@ -6,74 +6,92 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.add.AddFragment"> tools:context=".ui.add.AddFragment">
<ImageView <ScrollView
android:id="@+id/image"
android:layout_width="334dp"
android:layout_height="334dp"
android:layout_marginTop="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_menu_report_image"
android:contentDescription="@string/gallery" />
<ImageButton
android:id="@+id/cameraButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:src="@android:drawable/ic_menu_camera"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/image"
android:contentDescription="@string/camera" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/titleLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent">
android:layout_marginHorizontal="20dp"
android:layout_marginVertical="20dp"
android:hint="@string/title"
android:textColorHint="#6E6E6E"
app:layout_constraintTop_toBottomOf="@+id/cameraButton"
tools:layout_editor_absoluteX="20dp">
<com.google.android.material.textfield.TextInputEditText <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:paddingHorizontal="36dp" />
</com.google.android.material.textfield.TextInputLayout> <ImageView
android:id="@+id/image"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginTop="100dp"
android:contentDescription="@string/gallery"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_menu_report_image" />
<com.google.android.material.textfield.TextInputLayout <ImageButton
android:id="@+id/addressLayout" android:id="@+id/cameraButton"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp" android:layout_marginTop="16dp"
android:layout_marginVertical="10dp" android:contentDescription="@string/camera"
android:hint="@string/address" android:src="@android:drawable/ic_menu_camera"
android:textColorHint="#6E6E6E" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleLayout" app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteX="20dp"> app:layout_constraintTop_toBottomOf="@+id/image"
tools:ignore="MissingConstraints" />
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputLayout
android:id="@+id/address" android:id="@+id/titleLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="36dp" /> android:layout_marginHorizontal="20dp"
</com.google.android.material.textfield.TextInputLayout> android:layout_marginVertical="20dp"
android:hint="@string/title"
android:textColorHint="#6E6E6E"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cameraButton"
tools:ignore="MissingConstraints">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="36dp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/addressLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginVertical="10dp"
android:hint="@string/address"
android:textColorHint="#6E6E6E"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleLayout"
tools:ignore="MissingConstraints">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="36dp" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="8dp"
android:text="@string/send"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addressLayout"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button </ScrollView>
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addressLayout" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment