diff --git a/receiver/src/main/AndroidManifest.xml b/receiver/src/main/AndroidManifest.xml index e2f6ea6c..c4c0eac4 100644 --- a/receiver/src/main/AndroidManifest.xml +++ b/receiver/src/main/AndroidManifest.xml @@ -8,6 +8,17 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.Activities" /> + android:theme="@style/Theme.Activities"> + + + + + + + + + \ No newline at end of file diff --git a/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt b/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt index b3fe360c..3f5126b6 100644 --- a/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt +++ b/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt @@ -1,12 +1,43 @@ package otus.gpb.homework.activities.receiver +import android.graphics.drawable.Drawable import android.os.Bundle +import android.widget.ImageView +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity - +const val TITLEKEY = "title" +const val YEARKEY = "year" +const val DESCRIPTIONKEY = "description" class ReceiverActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_receiver) + + val titleView: TextView = findViewById(R.id.titleTextView) + val yearView: TextView = findViewById(R.id.yearTextView) + val descriptionView: TextView = findViewById(R.id.descriptionTextView) + val posterView: ImageView = findViewById(R.id.posterImageView) + + val title = getFromIntent(TITLEKEY) + + titleView.text = title + yearView.text = getFromIntent(YEARKEY) + descriptionView.text = getFromIntent(DESCRIPTIONKEY) + posterView.setImageDrawable(getPoster(title)) + } + + private fun getFromIntent(key: String): String { + return intent.getStringExtra(key) ?: "" + } + + private fun getPoster(title: String): Drawable? { + return when (title) { + "Славные парни" -> getDrawable(R.drawable.niceguys) + "Интерстеллар" -> getDrawable(R.drawable.interstellar) + else -> null + } + } + } diff --git a/sender/build.gradle b/sender/build.gradle index 9854ad15..bf64b151 100644 --- a/sender/build.gradle +++ b/sender/build.gradle @@ -40,4 +40,5 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.activity:activity:1.8.0' } \ No newline at end of file diff --git a/sender/src/main/AndroidManifest.xml b/sender/src/main/AndroidManifest.xml index 1bddc002..a33e6a76 100644 --- a/sender/src/main/AndroidManifest.xml +++ b/sender/src/main/AndroidManifest.xml @@ -7,6 +7,15 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/Theme.Activities" /> + android:theme="@style/Theme.Activities"> + + + + + + + \ No newline at end of file diff --git a/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt b/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt new file mode 100644 index 00000000..ab858330 --- /dev/null +++ b/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt @@ -0,0 +1,55 @@ +package otus.gpb.homework.activities.sender + +import android.content.Intent +import android.icu.util.ULocale +import android.net.Uri +import android.os.Bundle +import android.widget.Button +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import otus.gpb.homework.activities.receiver.R +import kotlin.jvm.java +import androidx.core.net.toUri + +class SenderActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_sender) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + + findViewById