Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ElBuenoPeso
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matis SPINELLI
ElBuenoPeso
Commits
946609c5
Commit
946609c5
authored
Feb 21, 2024
by
m-spi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enfin, une structure de page cohérente, et des boutons qui marchent (maybe)
parent
a7b30035
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
105 deletions
+109
-105
AddFragment.kt
...c/main/java/com/example/elbuenopeso/ui/add/AddFragment.kt
+16
-30
activity_main.xml
app/src/main/res/layout/activity_main.xml
+13
-13
fragment_add.xml
app/src/main/res/layout/fragment_add.xml
+80
-62
No files found.
app/src/main/java/com/example/elbuenopeso/ui/add/AddFragment.kt
View file @
946609c5
...
...
@@ -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..."
)
}
camera_open_id
.
setImageBitmap
(
image
)
binding
.
title
.
setText
(
"aaa"
)
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
)
}
}
}
)
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
...
...
@@ -87,7 +73,7 @@ class AddFragment : Fragment() {
binding
.
cameraButton
.
setOnClickListener
{
val
camera
=
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
)
gallery
ActivityResultLauncher
.
launch
(
camera
)
camera
ActivityResultLauncher
.
launch
(
camera
)
}
// val textView: TextView = binding.textNotifications
...
...
app/src/main/res/layout/activity_main.xml
View file @
946609c5
...
...
@@ -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
app/src/main/res/layout/fragment_add.xml
View file @
946609c5
...
...
@@ -6,74 +6,92 @@
android:layout_height=
"match_parent"
tools:context=
".ui.add.AddFragment"
>
<ImageView
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"
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
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"
>
android:layout_height=
"match_parent"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/title"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingHorizontal=
"36dp"
/>
android:layout_height=
"wrap_content"
>
</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
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_constraintTop_toBottomOf=
"@+id/titleLayout"
tools:layout_editor_absoluteX=
"20dp"
>
<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"
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>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/titleLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"20dp"
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
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"
/>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment