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
import com.example.elbuenopeso.databinding.FragmentAddBinding
@Suppress("DEPRECATION")
class AddFragment : Fragment() {
private var _binding: FragmentAddBinding? = null
......@@ -32,39 +33,24 @@ class AddFragment : Fragment() {
lateinit var click_image_id: ImageView
private val galleryActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult(),
ActivityResultCallback { fun onActivityResult(
requestCode: Int,
resultCode: Int,
data: Intent
) {
if (resultCode == Activity.RESULT_OK) {
val image = data.data as Uri
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
result -> run {
if (result.resultCode == Activity.RESULT_OK) {
val image = result?.data?.data as Uri
click_image_id.setImageURI(image)
}
}}
)
}
}
private var cameraActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult(),
ActivityResultCallback {
fun onActivityResult(
requestCode: Int,
resultCode: Int,
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...")
private val cameraActivityResultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
result -> run {
if (result.resultCode == Activity.RESULT_OK) {
val image = result.data?.extras?.get("data") as Bitmap?
click_image_id.setImageBitmap(image)
}
}
camera_open_id.setImageBitmap(image)
binding.title.setText("aaa")
}
}}
)
override fun onCreateView(
inflater: LayoutInflater,
......@@ -87,7 +73,7 @@ class AddFragment : Fragment() {
binding.cameraButton.setOnClickListener {
val camera = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
galleryActivityResultLauncher.launch(camera)
cameraActivityResultLauncher.launch(camera)
}
// val textView: TextView = binding.textNotifications
......
......@@ -7,6 +7,19 @@
android:layout_height="match_parent"
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
android:id="@+id/nav_view"
android:layout_width="0dp"
......@@ -19,17 +32,4 @@
app:layout_constraintRight_toRightOf="parent"
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>
\ No newline at end of file
......@@ -6,27 +6,36 @@
android:layout_height="match_parent"
tools:context=".ui.add.AddFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="334dp"
android:layout_height="334dp"
android:layout_marginTop="50dp"
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"
android:contentDescription="@string/gallery" />
app:srcCompat="@android:drawable/ic_menu_report_image" />
<ImageButton
android:id="@+id/cameraButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:contentDescription="@string/camera"
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" />
tools:ignore="MissingConstraints" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/titleLayout"
......@@ -36,15 +45,15 @@
android:layout_marginVertical="20dp"
android:hint="@string/title"
android:textColorHint="#6E6E6E"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cameraButton"
tools:layout_editor_absoluteX="20dp">
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
......@@ -55,8 +64,10 @@
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:layout_editor_absoluteX="20dp">
tools:ignore="MissingConstraints">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/address"
......@@ -69,11 +80,18 @@
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" />
app:layout_constraintTop_toBottomOf="@+id/addressLayout"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</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