-
Notifications
You must be signed in to change notification settings - Fork 0
Task/hw2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WentuM
wants to merge
2
commits into
master
Choose a base branch
from
task/hw2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Task/hw2 #2
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/example/androidpractice2020/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,26 @@ | ||
| package com.example.androidpractice2020 | ||
|
|
||
| import android.content.Intent | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import android.os.Bundle | ||
| import android.view.Menu | ||
| import android.widget.Toolbar | ||
| import kotlinx.android.synthetic.main.activity_main.* | ||
| import kotlinx.android.synthetic.main.activity_profile.* | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| setTitle(R.string.app_registration) | ||
| btn_registr.setOnClickListener { | ||
| val intent = Intent(this, ProfileActivity::class.java) | ||
| intent.putExtra("fName", et_Name.text.toString()) | ||
| intent.putExtra("fSurname", et_Surname.text.toString()) | ||
| intent.putExtra("fEmail", et_Email.text.toString()) | ||
| intent.putExtra("fGender", et_Gender.text.toString()) | ||
| startActivity(intent) | ||
| finish() | ||
| } | ||
| } | ||
| } |
146 changes: 146 additions & 0 deletions
146
app/src/main/java/com/example/androidpractice2020/ProfileActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| package com.example.androidpractice2020 | ||
|
|
||
| import android.app.Activity | ||
| import android.content.Intent | ||
| import android.graphics.BitmapFactory | ||
| import android.graphics.Color | ||
| import android.opengl.Visibility | ||
| import android.os.Bundle | ||
| import android.view.Menu | ||
| import android.view.MenuItem | ||
| import android.view.View | ||
| import android.widget.* | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import com.google.android.material.imageview.ShapeableImageView | ||
| import kotlinx.android.synthetic.main.activity_profile.* | ||
| import java.io.FileNotFoundException | ||
|
|
||
| //TODO: | ||
| //1) сохранение текущей записи на элементе(View/Edit) | ||
| //2) работа с default toolbar (поменять цвет, изменить расположение кнопок) supportactionbar | ||
| //3) запрет на нажатие кнопки редактирования isEnabled = false | ||
| //4) показывание кнопок на toolbar только при нажатии на редактирование, после нажатие на одну | ||
| // из кнопок, убирает просмотр этих кнопок invalidateOptionsMenu() | ||
| //5) спросить про предыдущую домашку на примере репозитория | ||
| //6) доступ к галереи телефона при нажатии на кнопку профиля | ||
| class ProfileActivity : AppCompatActivity() { | ||
| //библиотека glide | ||
| private var imageView: ImageView? = null | ||
| private val pickImage = 1 | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_profile) | ||
| setTitle(R.string.app_profile) | ||
| profile_image.setImageResource(R.drawable.first_picture) | ||
| etNameView.setTextColor(Color.BLACK) | ||
| etSurnameView.setTextColor(Color.BLACK) | ||
| etEmailView.setTextColor(Color.BLACK) | ||
| etGenderView.setTextColor(Color.BLACK) | ||
| etNameView.text = intent.getStringExtra("fName") | ||
| etSurnameView.text = intent.getStringExtra("fSurname") | ||
| etEmailView.text = intent.getStringExtra("fEmail") | ||
| etGenderView.text = intent.getStringExtra("fGender") | ||
| invisible(false) | ||
| btn_edit.setOnClickListener { | ||
| btn_edit.visibility = View.INVISIBLE | ||
| setTitle(R.string.app_edit) | ||
| editFirst(etNameView, etName) | ||
| editFirst(etSurnameView, etSurname) | ||
| editFirst(etEmailView, etEmail) | ||
| editFirst(etGenderView, etGender) | ||
| } | ||
| btn_exit.setOnClickListener { | ||
| val intent = Intent(this, MainActivity::class.java) | ||
| startActivity(intent) | ||
| finish() | ||
| } | ||
|
|
||
| //Связываемся с нашим ImageView: | ||
| imageView = findViewById<View>(R.id.profile_image) as ImageView | ||
| //Связываемся с нашей кнопкой Button: | ||
| val PickImage = | ||
| findViewById<View>(R.id.btn_photo) as Button | ||
| //Настраиваем для нее обработчик нажатий OnClickListener: | ||
| PickImage.setOnClickListener { //Вызываем стандартную галерею для выбора изображения с помощью Intent.ACTION_PICK: | ||
| val photoPickerIntent = Intent(Intent.ACTION_PICK) | ||
| //Тип получаемых объектов - image: | ||
| photoPickerIntent.type = "image/*" | ||
| //Запускаем переход с ожиданием обратного результата в виде информации об изображении: | ||
| startActivityForResult(photoPickerIntent, pickImage) | ||
| } | ||
| } | ||
|
|
||
| fun invisible(flag: Boolean) { | ||
| setTitle(R.string.app_profile) | ||
| etName.visibility = View.INVISIBLE | ||
| etSurname.visibility = View.INVISIBLE | ||
| etEmail.visibility = View.INVISIBLE | ||
| etSyte.visibility = View.INVISIBLE | ||
| etGender.visibility = View.INVISIBLE | ||
| etNumberPhone.visibility = View.INVISIBLE | ||
| } | ||
|
|
||
| fun edit(etView: TextView, etEdit: EditText) { | ||
| etView.text = etEdit.text.toString() | ||
| etView.visibility = View.VISIBLE | ||
| etEdit.visibility = View.INVISIBLE | ||
| } | ||
|
|
||
| fun editFirst(etView: TextView, etEdit: EditText) { | ||
| etView.visibility = View.INVISIBLE | ||
| etEdit.visibility = View.VISIBLE | ||
| } | ||
|
|
||
| fun cancel(etView: TextView, etEdit: EditText) { | ||
| etView.visibility = View.VISIBLE | ||
| etEdit.visibility = View.INVISIBLE | ||
| } | ||
|
|
||
| override fun onCreateOptionsMenu(menu: Menu?): Boolean { | ||
| menuInflater.inflate(R.menu.menu_action, menu) | ||
| return true | ||
| } | ||
|
|
||
| override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
| when (item.itemId) { | ||
| R.id.menu_save -> { | ||
| Toast.makeText(this, "Сохранено", Toast.LENGTH_SHORT).show() | ||
| edit(etNameView, etName) | ||
| edit(etSurnameView, etSurname) | ||
| edit(etEmailView, etEmail) | ||
| edit(etGenderView, etGender) | ||
| btn_edit.visibility = View.VISIBLE | ||
| } | ||
| R.id.menu_cancel -> { | ||
| Toast.makeText(this, "Отмена", Toast.LENGTH_SHORT).show() | ||
| cancel(etNameView, etName) | ||
| cancel(etSurnameView, etSurname) | ||
| cancel(etEmailView, etEmail) | ||
| cancel(etGenderView, etGender) | ||
| btn_edit.visibility = View.VISIBLE | ||
| } | ||
| } | ||
| return super.onOptionsItemSelected(item) | ||
| } | ||
|
|
||
| // Обрабатываем результат выбора в галерее: | ||
| override fun onActivityResult(requestCode: Int, resultCode: Int, imageReturnedIntent: Intent?) { | ||
| super.onActivityResult(requestCode, resultCode, imageReturnedIntent) | ||
| when (requestCode) { | ||
| pickImage -> if (resultCode == Activity.RESULT_OK) { | ||
| try { | ||
|
|
||
| //Получаем URI изображения, преобразуем его в Bitmap | ||
| //объект и отображаем в элементе ImageView нашего интерфейса: | ||
| val imageUri = imageReturnedIntent?.data | ||
| val imageStream = | ||
| contentResolver.openInputStream(imageUri!!) | ||
| val selectedImage = BitmapFactory.decodeStream(imageStream) | ||
| imageView!!.setImageBitmap(selectedImage) | ||
| } catch (e: FileNotFoundException) { | ||
| e.printStackTrace() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
|
||
| </selector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="108dp" | ||
| android:height="108dp" | ||
| android:viewportWidth="108" | ||
| android:viewportHeight="108" | ||
| android:tint="#010101"> | ||
| <group android:scaleX="2.61" | ||
| android:scaleY="2.61" | ||
| android:translateX="22.68" | ||
| android:translateY="22.68"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
| </group> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
|
||
| </selector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="108dp" | ||
| android:height="108dp" | ||
| android:viewportWidth="108" | ||
| android:viewportHeight="108" | ||
| android:tint="#151287"> | ||
| <group android:scaleX="2.61" | ||
| android:scaleY="2.61" | ||
| android:translateX="22.68" | ||
| android:translateY="22.68"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> | ||
| </group> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <item android:state_selected="true" android:color="#232B87" /> | ||
| <item android:color="#232B87" /> | ||
| </selector> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageView?