Skip to content
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
13 changes: 12 additions & 1 deletion receiver/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<activity
android:name=".ReceiverActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
package otus.gpb.homework.activities.receiver

import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class ReceiverActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_receiver)

val intent = intent.getBundleExtra("movie_bundle")

val title = intent?.getString("title")
val year = intent?.getString("year")
val description = intent?.getString("description")

val titleTextView = findViewById<TextView>(R.id.titleTextView)
val yearTextView = findViewById<TextView>(R.id.yearTextView)
val descriptionTextView = findViewById<TextView>(R.id.descriptionTextView)
val imageView = findViewById<ImageView>(R.id.posterImageView)

titleTextView.text = title
yearTextView.text = year
descriptionTextView.text = description

when (title) {
"Славные парни" -> imageView.setImageResource(R.drawable.niceguys)
"Интерстеллар" -> imageView.setImageResource(R.drawable.interstellar)
else -> {}
}
}
}
1 change: 1 addition & 0 deletions sender/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.11.0'
}
7 changes: 6 additions & 1 deletion sender/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Activities" />
android:theme="@style/Theme.Activities">
<activity
android:name="otus.gpb.homework.activities.sender.SenderActivity"
android:exported="false">
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package otus.gpb.homework.activities.sender

import android.content.Intent
import android.icu.util.ULocale
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 androidx.core.net.toUri
import java.util.Locale

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
}

val googleMapsBtn = findViewById<Button>(R.id.to_google_maps)
val sendEmailBtn = findViewById<Button>(R.id.send_email)
val openReceiver = findViewById<Button>(R.id.open_receiver)

googleMapsBtn.setOnClickListener {
val uriRestaurant = "geo:0,0?q=restaurants".toUri()
val mapIntent =
Intent(Intent.ACTION_VIEW, uriRestaurant)
.setPackage("com.google.android.apps.maps")
startActivity(mapIntent)
}

sendEmailBtn.setOnClickListener {
val emailIntent = Intent(Intent.ACTION_SEND)
emailIntent.type = "*/*"
emailIntent.putExtra(Intent.EXTRA_EMAIL, "android@otus.ru")
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Important email")
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email text")
startActivity(emailIntent)
}

openReceiver.setOnClickListener {
val movie1 = Payload(
title = "Славные парни",
year = "2016",
description = "Что бывает, когда напарником брутального костолома становится субтильный лопух? Наемный охранник Джексон Хили и частный детектив Холланд Марч вынуждены работать в паре, чтобы распутать плевое дело о пропавшей девушке, которое оборачивается преступлением века. Смогут ли парни разгадать сложный ребус, если у каждого из них – свои, весьма индивидуальные методы."
)
val movie2 = Payload(
title = "Интерстеллар",
year = "2014",
description = "Когда засуха, пыльные бури и вымирание растений приводят человечество к продовольственному кризису, коллектив исследователей и учёных отправляется сквозь червоточину (которая предположительно соединяет области пространства-времени через большое расстояние) в путешествие, чтобы превзойти прежние ограничения для космических путешествий человека и найти планету с подходящими для человечества условиями."
)

val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
intent.addCategory(Intent.CATEGORY_DEFAULT)

val bundle = Bundle()

bundle.putString("title", movie1.title)
bundle.putString("year", movie1.year)
bundle.putString("description", movie1.description)

intent.putExtra("movie_bundle", bundle)
}
}
}
40 changes: 40 additions & 0 deletions sender/src/main/res/layout/activity_sender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="otus.gpb.homework.activities.sender.SenderActivity">

<Button
android:id="@+id/to_google_maps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/to_google_maps"
app:layout_constraintBottom_toTopOf="@id/send_email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/send_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_email"
app:layout_constraintBottom_toTopOf="@id/open_receiver"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/to_google_maps" />

<Button
android:id="@+id/open_receiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_receiver"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/send_email" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions sender/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<resources>
<string name="app_name">Sender</string>
<string name="to_google_maps">To Google Maps</string>
<string name="send_email">Send Email</string>
<string name="open_receiver">Open Receiver</string>
</resources>