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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.4.0' apply false
id 'com.android.library' version '8.4.0' apply false
id 'com.android.application' version '8.12.2' apply false
id 'com.android.library' version '8.12.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id "io.gitlab.arturbosch.detekt" version "1.21.0"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Aug 27 13:57:30 MSK 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
4 changes: 2 additions & 2 deletions receiver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
}

android {
compileSdk 34
compileSdk 36

defaultConfig {
applicationId "otus.gpb.homework.activities.receiver"
minSdk 23
targetSdk 34
targetSdk 36
versionCode 1
versionName "1.0"

Expand Down
12 changes: 11 additions & 1 deletion receiver/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
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.receiver.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,40 @@
package otus.gpb.homework.activities.receiver

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

class ReceiverActivity : AppCompatActivity() {
private var titleView: TextView? = null
private var yearView: TextView? = null
private var descrView: TextView? = null
private lateinit var posterView: ImageView

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

titleView = findViewById(R.id.titleTextView)
yearView = findViewById(R.id.yearTextView)
descrView = findViewById(R.id.descriptionTextView)
posterView = findViewById(R.id.posterImageView)

val title = intent.extras?.getString("title")
titleView?.text = title
yearView?.text = intent.extras?.getString("year")
descrView?.text = intent.extras?.getString("description")

when(title){
"Interstellar" -> {
val drawable = ContextCompat.getDrawable(this, R.drawable.interstellar)
posterView.setImageDrawable(drawable)
}
"Nice guys" -> {
val drawable = ContextCompat.getDrawable(this, R.drawable.niceguys)
posterView.setImageDrawable(drawable)
}
}
}
}
1 change: 1 addition & 0 deletions receiver/src/main/res/layout/activity_receiver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="32dp"
android:textColor="#212121"
android:textSize="24dp"
app:layout_constraintStart_toEndOf="@+id/posterImageView"
Expand Down
5 changes: 3 additions & 2 deletions sender/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 34
compileSdk 36

defaultConfig {
applicationId "otus.gpb.homework.activities.sender"
minSdk 23
targetSdk 34
targetSdk 36
versionCode 1
versionName "1.0"

Expand Down 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.10.1'
}
11 changes: 10 additions & 1 deletion sender/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<activity
android:name="otus.gpb.homework.activities.sender.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
@@ -0,0 +1,70 @@
package otus.gpb.homework.activities.sender

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import otus.gpb.homework.activities.receiver.R
import kotlin.Exception


class SenderActivity : AppCompatActivity() {
private var buttonMap: Button? = null
private var buttonMail: Button? = null
private var buttonReceiver: Button? = null


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sender)
buttonMap = findViewById(R.id.button)
buttonMail = findViewById(R.id.button2)
buttonReceiver = findViewById(R.id.button3)

buttonMap?.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=restaurants")).setPackage("com.google.android.apps.maps")
try {
startActivity(intent)
} catch (e: Exception) {
Toast.makeText(
this,
"Не удалось открыть карту",
Toast.LENGTH_SHORT
).show()
}
}
buttonMail?.setOnClickListener {
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:android@otus.ru?subject=\"Отзыв о курсе обучения\"&body=\"Курс очень понравился. Получил много полезной информации и навыков.\""))
try {
startActivity(intent)
} catch (e: Exception) {
Toast.makeText(
this,
"Не удалось открыть почтовый клиент",
Toast.LENGTH_SHORT
).show()
}
}
buttonReceiver?.setOnClickListener {
val intent = Intent(Intent.ACTION_SEND)
intent.setType("text/plain")
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.putExtra("title", "Interstellar")
intent.putExtra("year", "2014")
intent.putExtra("description",
"Когда засуха, пыльные бури и вымирание растений приводят человечество к продовольственному кризису, коллектив исследователей и учёных отправляется сквозь червоточину (которая предположительно соединяет области пространства-времени через большое расстояние) в путешествие, чтобы превзойти прежние ограничения для космических путешествий человека и найти планету с подходящими для человечества условиями."
)
try {
startActivity(intent)
} catch (e: Exception) {
Toast.makeText(
this,
"Не удалось открыть Receiver",
Toast.LENGTH_SHORT
).show()
}
}
}
}
47 changes: 47 additions & 0 deletions sender/src/main/res/layout/activity_sender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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/button"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="To Google Maps"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />

<Button
android:id="@+id/button2"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:text="Send Email"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button"
tools:visibility="visible" />

<Button
android:id="@+id/button3"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="Open Receiver"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>