Skip to content

homework10 #35

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ plugins {
}

android {
compileSdk 32
namespace 'otus.gpb.homework.viewandresources'
compileSdk 34

defaultConfig {
applicationId "otus.gpb.homework.viewandresources"
minSdk 23
targetSdk 32
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -23,17 +24,20 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
buildFeatures {
viewBinding = true
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}
11 changes: 5 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="otus.gpb.homework.viewandresources">
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
Expand All @@ -15,12 +14,12 @@
tools:targetApi="31">
<activity
android:name=".CartActivity"
android:label="Cart"
android:exported="false" />
android:exported="false"
android:label="Cart" />
<activity
android:name=".ContactsActivity"
android:label="Contacts"
android:exported="false" />
android:exported="false"
android:label="Contacts" />
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/otus/gpb/homework/viewandresources/Item.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package otus.gpb.homework.viewandresources

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.core.content.withStyledAttributes
import otus.gpb.homework.viewandresources.databinding.ItemBinding

class Item @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : LinearLayout(context, attrs, defStyleAttr) {
private val binding: ItemBinding = ItemBinding.inflate(LayoutInflater.from(context), this)

init {
initParams(attrs, defStyleAttr)
}

private fun initParams(attrs: AttributeSet?, defStyleAttr: Int) = with(binding) {
context.withStyledAttributes(attrs, R.styleable.Item, defStyleAttr) {
val imageResId = getResourceId(R.styleable.Item_itemImage, 0)
if (imageResId != 0) {
itemImage.setImageResource(imageResId)
}

val name = getString(R.styleable.Item_itemName) ?: "Name"
itemName.text = name

val description = getString(R.styleable.Item_itemDescription) ?: "Description"
itemDescription.text = description

val price = getString(R.styleable.Item_itemPrice) ?: "Price"
itemPrice.text = price
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package otus.gpb.homework.viewandresources

import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -19,9 +20,10 @@ class MainActivity : AppCompatActivity() {
}

findViewById<Button>(R.id.signin_button).setOnClickListener {
MaterialAlertDialogBuilder(this)
.setView(R.layout.dialog_signin)
.show()
val contentView = LayoutInflater.from(this)
.inflate(R.layout.dialog_signin, null, false)

AlertDialog.Builder(this, R.style.Dialog).setView(contentView).show()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillColor="#FFFFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M8,0C9.061,0 10.078,0.421 10.828,1.172C11.579,1.922 12,2.939 12,4C12,5.061 11.579,6.078 10.828,6.828C10.078,7.579 9.061,8 8,8C6.939,8 5.922,7.579 5.172,6.828C4.421,6.078 4,5.061 4,4C4,2.939 4.421,1.922 5.172,1.172C5.922,0.421 6.939,0 8,0ZM8,10C12.42,10 16,11.79 16,14V16H0V14C0,11.79 3.58,10 8,10Z"
android:fillColor="#979797" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/action_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="4dp"
android:height="16dp"
android:viewportWidth="4"
android:viewportHeight="16">
<path
android:pathData="M2,4C3.1,4 4,3.1 4,2C4,0.9 3.1,0 2,0C0.9,0 0,0.9 0,2C0,3.1 0.9,4 2,4ZM2,6C0.9,6 0,6.9 0,8C0,9.1 0.9,10 2,10C3.1,10 4,9.1 4,8C4,6.9 3.1,6 2,6ZM2,12C0.9,12 0,12.9 0,14C0,15.1 0.9,16 2,16C3.1,16 4,15.1 4,14C4,12.9 3.1,12 2,12Z"
android:fillColor="#FFFFFFFF" />
</vector>
Binary file added app/src/main/res/drawable/alarm_clock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/arrow_dropdown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="10dp"
android:height="5dp"
android:viewportWidth="10"
android:viewportHeight="5">
<path
android:pathData="M0,0L5,5L10,0L0,0Z"
android:fillColor="#979797" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/arrow_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M16,7H3.83L9.42,1.41L8,0L0,8L8,16L9.41,14.59L3.83,9H16V7Z"
android:fillColor="#FFFFFFFF" />
</vector>
Binary file added app/src/main/res/drawable/cactus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/calendar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="20dp"
android:viewportWidth="18"
android:viewportHeight="20">
<path
android:pathData="M16,18H2V7H16V18ZM13,0V2H5V0H3V2H2C0.89,2 0,2.89 0,4V18C0,18.53 0.211,19.039 0.586,19.414C0.961,19.789 1.47,20 2,20H16C16.53,20 17.039,19.789 17.414,19.414C17.789,19.039 18,18.53 18,18V4C18,2.89 17.1,2 16,2H15V0H13ZM14,11H9V16H14V11Z"
android:fillColor="#979797" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/cross.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="10dp"
android:height="10dp"
android:viewportWidth="10"
android:viewportHeight="10">
<path
android:pathData="M9.667,1.273L8.727,0.333L5,4.06L1.273,0.333L0.333,1.273L4.06,5L0.333,8.727L1.273,9.667L5,5.94L8.727,9.667L9.667,8.727L5.94,5L9.667,1.273Z"
android:fillColor="#E74C3C" />
</vector>
Binary file added app/src/main/res/drawable/cupcake.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/dialog_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/colorOnBackground" />
<corners android:radius="4dp" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/edit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:pathData="M17.71,4.043C18.1,3.652 18.1,3.003 17.71,2.632L15.37,0.292C15,-0.097 14.35,-0.097 13.96,0.292L12.12,2.122L15.87,5.872L17.71,4.043ZM0,14.252V18.003H3.75L14.81,6.932L11.06,3.182L0,14.252Z"
android:fillColor="#979797" />
</vector>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/input_box_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/inputEditTextBackground" />
<corners
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
</shape>
</item>

<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="?attr/inputEditTextUnderline"
android:dashWidth="0px" />
</shape>
</item>
</layer-list>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/map_marker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="20dp"
android:viewportWidth="14"
android:viewportHeight="20">
<path
android:pathData="M7,9.5C6.337,9.5 5.701,9.237 5.232,8.768C4.763,8.299 4.5,7.663 4.5,7C4.5,6.337 4.763,5.701 5.232,5.232C5.701,4.763 6.337,4.5 7,4.5C7.663,4.5 8.299,4.763 8.768,5.232C9.237,5.701 9.5,6.337 9.5,7C9.5,7.328 9.435,7.653 9.31,7.957C9.184,8.26 9,8.536 8.768,8.768C8.536,9 8.26,9.184 7.957,9.31C7.653,9.435 7.328,9.5 7,9.5ZM7,0C5.143,0 3.363,0.737 2.05,2.05C0.737,3.363 0,5.143 0,7C0,12.25 7,20 7,20C7,20 14,12.25 14,7C14,5.143 13.262,3.363 11.95,2.05C10.637,0.737 8.857,0 7,0Z"
android:fillColor="#979797" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/phone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:pathData="M3.62,7.79C5.06,10.62 7.38,12.94 10.21,14.38L12.41,12.18C12.69,11.9 13.08,11.82 13.43,11.93C14.55,12.3 15.75,12.5 17,12.5C17.265,12.5 17.52,12.605 17.707,12.793C17.895,12.98 18,13.235 18,13.5V17C18,17.265 17.895,17.52 17.707,17.707C17.52,17.895 17.265,18 17,18C12.491,18 8.167,16.209 4.979,13.021C1.791,9.833 0,5.509 0,1C0,0.735 0.105,0.48 0.293,0.293C0.48,0.105 0.735,0 1,0H4.5C4.765,0 5.02,0.105 5.207,0.293C5.395,0.48 5.5,0.735 5.5,1C5.5,2.25 5.7,3.45 6.07,4.57C6.18,4.92 6.1,5.31 5.82,5.59L3.62,7.79Z"
android:fillColor="#979797" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:pathData="M6.5,0C8.224,0 9.877,0.685 11.096,1.904C12.315,3.123 13,4.776 13,6.5C13,8.11 12.41,9.59 11.44,10.73L11.71,11H12.5L17.5,16L16,17.5L11,12.5V11.71L10.73,11.44C9.59,12.41 8.11,13 6.5,13C4.776,13 3.123,12.315 1.904,11.096C0.685,9.877 0,8.224 0,6.5C0,4.776 0.685,3.123 1.904,1.904C3.123,0.685 4.776,0 6.5,0ZM6.5,2C4,2 2,4 2,6.5C2,9 4,11 6.5,11C9,11 11,9 11,6.5C11,4 9,2 6.5,2Z"
android:fillColor="#FFFFFFFF" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/tag_heart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M19.41,9.58L10.41,0.58C10.05,0.22 9.55,0 9,0H2C1.47,0 0.961,0.211 0.586,0.586C0.211,0.961 0,1.47 0,2V9C0,9.55 0.22,10.05 0.59,10.42L9.59,19.42C9.95,19.78 10.45,20 11,20C11.55,20 12.05,19.78 12.41,19.41L19.41,12.41C19.78,12.05 20,11.55 20,11C20,10.45 19.77,9.94 19.41,9.58ZM3.5,5C3.102,5 2.721,4.842 2.439,4.561C2.158,4.279 2,3.898 2,3.5C2,3.102 2.158,2.721 2.439,2.439C2.721,2.158 3.102,2 3.5,2C3.898,2 4.279,2.158 4.561,2.439C4.842,2.721 5,3.102 5,3.5C5,3.898 4.842,4.279 4.561,4.561C4.279,4.842 3.898,5 3.5,5ZM15.27,13.27L11,17.54L6.73,13.27C6.28,12.81 6,12.19 6,11.5C6,10.837 6.263,10.201 6.732,9.732C7.201,9.263 7.837,9 8.5,9C9.19,9 9.82,9.28 10.27,9.74L11,10.46L11.73,9.73C12.18,9.28 12.81,9 13.5,9C14.163,9 14.799,9.263 15.268,9.732C15.737,10.201 16,10.837 16,11.5C16,12.19 15.72,12.82 15.27,13.27Z"
android:fillColor="#FFFFFFFF" />
</vector>
Binary file added app/src/main/res/drawable/vinyls.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/wallet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="19dp"
android:height="18dp"
android:viewportWidth="19"
android:viewportHeight="18">
<path
android:pathData="M18,15V16C18,16.53 17.789,17.039 17.414,17.414C17.039,17.789 16.53,18 16,18H2C0.89,18 0,17.1 0,16V2C0,1.47 0.211,0.961 0.586,0.586C0.961,0.211 1.47,0 2,0H16C16.53,0 17.039,0.211 17.414,0.586C17.789,0.961 18,1.47 18,2V3H9C7.89,3 7,3.9 7,5V13C7,13.53 7.211,14.039 7.586,14.414C7.961,14.789 8.47,15 9,15H18ZM9,13H19V5H9V13ZM13,10.5C12.602,10.5 12.221,10.342 11.939,10.061C11.658,9.779 11.5,9.398 11.5,9C11.5,8.602 11.658,8.221 11.939,7.939C12.221,7.658 12.602,7.5 13,7.5C13.398,7.5 13.779,7.658 14.061,7.939C14.342,8.221 14.5,8.602 14.5,9C14.5,9.398 14.342,9.779 14.061,10.061C13.779,10.342 13.398,10.5 13,10.5Z"
android:fillColor="#979797" />
</vector>
Binary file added app/src/main/res/font/roboto.ttf
Binary file not shown.
Loading