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
3 changes: 3 additions & 0 deletions receiver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

dependencies {
Expand Down
18 changes: 16 additions & 2 deletions receiver/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Activities" />
android:theme="@style/Theme.Activities">

</manifest>
<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
Expand Up @@ -2,11 +2,34 @@ package otus.gpb.homework.activities.receiver

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import otus.gpb.homework.activities.receiver.databinding.ActivityReceiverBinding

class ReceiverActivity : AppCompatActivity() {

private lateinit var binding: ActivityReceiverBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_receiver)
binding = ActivityReceiverBinding.inflate(layoutInflater).also {
setContentView(it.root)
}

val title = intent.getStringExtra("title")

binding.titleTextView.text = title
binding.yearTextView.text = intent.getStringExtra("year")
binding.descriptionTextView.text = intent.getStringExtra("description")

binding.posterImageView.setImageDrawable(
AppCompatResources.getDrawable(
this,
when (title) {
"Славные парни" -> R.drawable.niceguys
"Интерстеллар" -> R.drawable.interstellar
else -> -1
}
)
)
}
}
}
7 changes: 4 additions & 3 deletions receiver/src/main/res/layout/activity_receiver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:layout_height="180dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/poster"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/interstellar" />
Expand All @@ -22,7 +23,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:textColor="#212121"
android:textSize="24dp"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="@+id/posterImageView"
app:layout_constraintTop_toTopOf="@+id/posterImageView"
tools:text="Interstellar" />
Expand All @@ -35,7 +36,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:textColor="#B3212121"
android:textSize="16dp"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/posterImageView"
Expand All @@ -47,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#80212121"
android:textSize="14dp"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@+id/titleTextView"
app:layout_constraintTop_toBottomOf="@+id/titleTextView"
tools:text="2014" />
Expand Down
1 change: 1 addition & 0 deletions receiver/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Receiver</string>
<string name="poster">poster</string>
</resources>
4 changes: 4 additions & 0 deletions sender/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}
}

dependencies {
Expand Down
19 changes: 17 additions & 2 deletions sender/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Activities" />
android:theme="@style/Theme.Activities">

</manifest>
<activity
android:name=".SenderActivity"
android:exported="true">

<intent-filter>

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ data class Payload(
val title: String,
val year: String,
val description: String
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package otus.gpb.homework.activities.sender

import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import otus.gpb.homework.activities.sender.databinding.ActivitySenderBinding

class SenderActivity : AppCompatActivity() {

private lateinit var binding: ActivitySenderBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivitySenderBinding.inflate(layoutInflater).also {
setContentView(it.root)
}

binding.btnToGoogleMaps.setOnClickListener {
val geoUriString = "geo:0,0?q=Moscow+restaurants&z=8"
val geoUri = Uri.parse(geoUriString)
val intent = Intent(Intent.ACTION_VIEW).apply {
data = geoUri
setPackage("com.google.android.apps.maps")
}

startActivity(intent)
}

binding.btnSendEmail.setOnClickListener {
val email = arrayOf("android@otus.ru")
val intent = Intent(Intent.ACTION_SENDTO).apply {
putExtra(Intent.EXTRA_EMAIL, email)
putExtra(Intent.EXTRA_SUBJECT, "Homework")
putExtra(Intent.EXTRA_TEXT, "Some text")
data = Uri.parse("mailto:")
}

startActivity(intent)
}

binding.btnOpenReceiver.setOnClickListener {
val intent = Intent(Intent.ACTION_SEND).apply {
addCategory(Intent.CATEGORY_DEFAULT)
type = "text/plain"
putExtra("title", getString(R.string.title))
putExtra("year", getString(R.string.year))
putExtra("description", getString(R.string.description))
}

startActivity(intent)
}
}
}
43 changes: 43 additions & 0 deletions sender/src/main/res/layout/activity_sender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgActivity"
tools:context=".SenderActivity">

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

<Button
android:id="@+id/btn_send_email"
style="@style/CustomButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_email"
app:layout_constraintBottom_toTopOf="@id/btn_open_receiver"
app:layout_constraintEnd_toEndOf="@id/btn_to_google_maps"
app:layout_constraintStart_toStartOf="@id/btn_to_google_maps"
app:layout_constraintTop_toBottomOf="@id/btn_to_google_maps" />

<Button
android:id="@+id/btn_open_receiver"
style="@style/CustomButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_receiver"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/btn_to_google_maps"
app:layout_constraintStart_toStartOf="@id/btn_to_google_maps"
app:layout_constraintTop_toBottomOf="@id/btn_send_email" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 4 additions & 0 deletions sender/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>

<color name="bgActivity">#C0C0C0</color>
<color name="darkBlue">#00008B</color>
<color name="gold">#FFD700</color>
</resources>
9 changes: 8 additions & 1 deletion sender/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<resources>
<string name="app_name">Sender</string>
</resources>
<string name="to_google_maps">To Google Maps</string>
<string name="send_email">Send Email</string>
<string name="open_receiver">Open Receiver</string>

<string name="title">Славные парни</string>
<string name="year">2016</string>
<string name="description">Что бывает, когда напарником брутального костолома становится субтильный лопух? Наемный охранник Джексон Хили и частный детектив Холланд Марч вынуждены работать в паре, чтобы распутать плевое дело о пропавшей девушке, которое оборачивается преступлением века. Смогут ли парни разгадать сложный ребус, если у каждого из них – свои, весьма индивидуальные методы.</string>
</resources>
9 changes: 9 additions & 0 deletions sender/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>

<style name="CustomButtonStyle">
<item name="android:textSize">32sp</item>
<item name="android:textAllCaps">false</item>
<item name="android:textColor">@color/gold</item>
<item name="android:backgroundTint">@color/darkBlue</item>

</style>

</resources>