diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 608e135..1153d26 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,9 @@ + android:exported="false" + android:screenOrientation="portrait" + /> + + \ No newline at end of file diff --git a/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt b/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt index b6cbf73..336733d 100644 --- a/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt +++ b/app/src/main/java/otus/gpb/homework/viewandresources/CartActivity.kt @@ -1,11 +1,82 @@ package otus.gpb.homework.viewandresources +import android.content.Context import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.ImageView +import android.widget.ListView +import android.widget.TextView +import android.widget.Toast +import com.google.android.material.appbar.MaterialToolbar +import com.google.android.material.button.MaterialButton class CartActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + //setTheme(R.style.Theme_MyTheme) // это работает + setContentView(R.layout.activity_cart) + + findViewById(R.id.btnClose).setOnClickListener { + Toast.makeText(this, "btnClose", Toast.LENGTH_SHORT).show() + } + + findViewById(R.id.buttonPlaceOrder).setOnClickListener { + Toast.makeText(this, "buttonPlaceOrder", Toast.LENGTH_SHORT).show() + } + + findViewById(R.id.topAppBar).setNavigationOnClickListener { + finish() + } + + + val listView: ListView = findViewById(R.id.listItems) + + val items = ArrayList() + for(i in 1..4) { + items.add(ItemData("Item $i", "Category", "Supporting line text lorem ipsum...", "$i$", R.drawable.ic_shape_outline)) + } + + val listAdapter = ListAdapter(this, items) + listView.adapter = listAdapter } +} + +class ItemData( + var name: String, + var category: String, + var description: String, + var price: String, + var image: Int +) + +class ListAdapter(context: Context, dataArrayList: ArrayList?) : + ArrayAdapter(context, R.layout.list_item, dataArrayList!!) { + + override fun getView(position: Int, view: View?, parent: ViewGroup): View { + var view = view + val listData = getItem(position) + if (view == null) { + view = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false) + } + val listImage = view!!.findViewById(R.id.imageView) + val listName = view.findViewById(R.id.textViewName) + val listCategory = view.findViewById(R.id.textViewCategory) + val listDescription = view.findViewById(R.id.textViewDescription) + val listPrice = view.findViewById(R.id.textViewPrice) + + listImage.setImageResource(listData!!.image) + listName.text = listData.name + listCategory.text = listData.category + listDescription.text = listData.description + listPrice.text = listData.price + + return view + } } \ No newline at end of file diff --git a/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt b/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt index 25f1ffb..16fb4b3 100644 --- a/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt +++ b/app/src/main/java/otus/gpb/homework/viewandresources/ContactsActivity.kt @@ -2,10 +2,42 @@ package otus.gpb.homework.viewandresources import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.widget.ArrayAdapter +import android.widget.AutoCompleteTextView +import android.widget.Toast +import androidx.appcompat.app.ActionBar +import androidx.core.content.ContentProviderCompat.requireContext +import com.google.android.material.appbar.MaterialToolbar +import com.google.android.material.textview.MaterialTextView +import com.google.android.material.textfield.MaterialAutoCompleteTextView +import com.google.android.material.textfield.TextInputLayout class ContactsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_contacts) + + var textField = findViewById(R.id.dropDownPhoneType) + val items = listOf("Mobile", "Stationary") + val adapter = ArrayAdapter(this, R.layout.list_item, items) + (textField.editText as? AutoCompleteTextView)?.setAdapter(adapter) + + var topAppBar: MaterialToolbar = findViewById(R.id.topAppBar) + topAppBar.setNavigationOnClickListener { + finish() + } + topAppBar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.attach -> { + Toast.makeText(this, "Attach", Toast.LENGTH_SHORT).show() + true + } + R.id.more -> { + Toast.makeText(this, "More", Toast.LENGTH_SHORT).show() + true + } + else -> false + } + } } } \ No newline at end of file diff --git a/app/src/main/res/drawable/cat.jpeg b/app/src/main/res/drawable/cat.jpeg new file mode 100644 index 0000000..3d7f8c7 Binary files /dev/null and b/app/src/main/res/drawable/cat.jpeg differ diff --git a/app/src/main/res/drawable/ic_account.xml b/app/src/main/res/drawable/ic_account.xml new file mode 100644 index 0000000..a3cbd5f --- /dev/null +++ b/app/src/main/res/drawable/ic_account.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_arrow_left.xml b/app/src/main/res/drawable/ic_arrow_left.xml new file mode 100644 index 0000000..828f7a8 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_left.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_bookmark_outline.xml b/app/src/main/res/drawable/ic_bookmark_outline.xml new file mode 100644 index 0000000..057a729 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_outline.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_calendar_badge.xml b/app/src/main/res/drawable/ic_calendar_badge.xml new file mode 100644 index 0000000..ba8390f --- /dev/null +++ b/app/src/main/res/drawable/ic_calendar_badge.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_cellphone_check.xml b/app/src/main/res/drawable/ic_cellphone_check.xml new file mode 100644 index 0000000..3a71709 --- /dev/null +++ b/app/src/main/res/drawable/ic_cellphone_check.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_close_circle.xml b/app/src/main/res/drawable/ic_close_circle.xml new file mode 100644 index 0000000..4ec46d5 --- /dev/null +++ b/app/src/main/res/drawable/ic_close_circle.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_dots_vertical.xml b/app/src/main/res/drawable/ic_dots_vertical.xml new file mode 100644 index 0000000..f2be274 --- /dev/null +++ b/app/src/main/res/drawable/ic_dots_vertical.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_emoticon.xml b/app/src/main/res/drawable/ic_emoticon.xml new file mode 100644 index 0000000..49ce120 --- /dev/null +++ b/app/src/main/res/drawable/ic_emoticon.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_eye_outline.xml b/app/src/main/res/drawable/ic_eye_outline.xml new file mode 100644 index 0000000..de25261 --- /dev/null +++ b/app/src/main/res/drawable/ic_eye_outline.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_down.xml b/app/src/main/res/drawable/ic_menu_down.xml new file mode 100644 index 0000000..0fb0589 --- /dev/null +++ b/app/src/main/res/drawable/ic_menu_down.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_microphone.xml b/app/src/main/res/drawable/ic_microphone.xml new file mode 100644 index 0000000..ed375ff --- /dev/null +++ b/app/src/main/res/drawable/ic_microphone.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_paperclip.xml b/app/src/main/res/drawable/ic_paperclip.xml new file mode 100644 index 0000000..f0884c7 --- /dev/null +++ b/app/src/main/res/drawable/ic_paperclip.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_shape_outline.xml b/app/src/main/res/drawable/ic_shape_outline.xml new file mode 100644 index 0000000..a141085 --- /dev/null +++ b/app/src/main/res/drawable/ic_shape_outline.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/font/roboto.xml b/app/src/main/res/font/roboto.xml new file mode 100644 index 0000000..2641caf --- /dev/null +++ b/app/src/main/res/font/roboto.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/font/roboto_light.xml b/app/src/main/res/font/roboto_light.xml new file mode 100644 index 0000000..28fbc0d --- /dev/null +++ b/app/src/main/res/font/roboto_light.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/layout/activity_cart.xml b/app/src/main/res/layout/activity_cart.xml index 57dc4d4..2fe9c40 100644 --- a/app/src/main/res/layout/activity_cart.xml +++ b/app/src/main/res/layout/activity_cart.xml @@ -4,6 +4,197 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".CartActivity"> + android:orientation="vertical" + tools:context=".CartActivity" + android:padding="10dp" + > + + + + + + + + + + +