From bd9cd8c827716cb55dc7f50fbe2dd7399d95a125 Mon Sep 17 00:00:00 2001 From: Igor Alekseev Date: Sun, 17 Nov 2024 17:36:59 +0300 Subject: [PATCH] activity 3 dz Alekseev Igor --- app/build.gradle | 4 + app/src/main/AndroidManifest.xml | 21 ++- .../activities/EditProfileActivity.kt | 151 +++++++++++++++++- .../homework/activities/FillFormActivity.kt | 32 ++++ .../main/res/layout/activity_fill_form.xml | 62 +++++++ app/src/main/res/xml/file_paths.xml | 6 + 6 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/otus/gpb/homework/activities/FillFormActivity.kt create mode 100644 app/src/main/res/layout/activity_fill_form.xml create mode 100644 app/src/main/res/xml/file_paths.xml diff --git a/app/build.gradle b/app/build.gradle index 57688408..9ee1f90c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,4 +60,8 @@ dependencies { implementation 'androidx.activity:activity-ktx:1.9.0' implementation 'androidx.fragment:fragment-ktx:1.7.1' implementation 'com.squareup.picasso:picasso:2.71828' + implementation 'androidx.compose.runtime:runtime-android:1.7.5' + implementation 'androidx.compose.ui:ui-android:1.7.5' + implementation 'androidx.compose.material3:material3-android:1.3.1' + implementation 'androidx.activity:activity:1.9.3' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e3d3319b..c7b7dd10 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,14 @@ + + + + + + - + @@ -22,6 +32,15 @@ + + + \ No newline at end of file diff --git a/app/src/main/java/otus/gpb/homework/activities/EditProfileActivity.kt b/app/src/main/java/otus/gpb/homework/activities/EditProfileActivity.kt index d55ee922..114fba54 100644 --- a/app/src/main/java/otus/gpb/homework/activities/EditProfileActivity.kt +++ b/app/src/main/java/otus/gpb/homework/activities/EditProfileActivity.kt @@ -1,14 +1,41 @@ package otus.gpb.homework.activities +import android.Manifest +import android.app.AlertDialog +import android.content.Context +import android.content.DialogInterface +import android.content.Intent +import android.content.pm.PackageManager +import android.graphics.Bitmap import android.graphics.BitmapFactory import android.net.Uri import android.os.Bundle +import android.os.Environment +import android.provider.MediaStore +import android.provider.Settings +import android.util.Log +import android.widget.Button import android.widget.ImageView +import android.widget.TextView +import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar +import androidx.core.content.ContentProviderCompat.requireContext +import androidx.core.content.FileProvider +import androidx.core.graphics.drawable.toBitmap +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.FileOutputStream +import java.io.IOException + +const val KEY_FIRST_NAME = "FIRST_NAME" +const val KEY_SECOND_NAME = "SECOND_NAME" +const val KEY_AGE = "AGE" class EditProfileActivity : AppCompatActivity() { + private enum class AlertsDlg {DLG_PHOTO, DLG_SECOND_CAMERA_PERMISSION_REQ, DLG_OPEN_SETTINGS} + private enum class Menu(val value: Int) { TAKE_PHOTO(0), SELECT_PHOTO(1)} private lateinit var imageView: ImageView override fun onCreate(savedInstanceState: Bundle?) { @@ -28,6 +55,98 @@ class EditProfileActivity : AppCompatActivity() { } } } + + findViewById(R.id.imageview_photo).setOnClickListener { + AlertDialog.Builder(this).apply { + setTitle("Фото") + setIcon(android.R.drawable.ic_dialog_info) + setItems(arrayOf("Сделать фото", "Выбрать фото"), AlertsDlgClickListener(AlertsDlg.DLG_PHOTO)) + setNegativeButton("Отмена", null) + show() + } + } + + findViewById