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
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 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 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id 'com.android.application' version '8.12.3' apply false
id 'com.android.library' version '8.12.3' apply false
id 'org.jetbrains.kotlin.android' version '2.2.0' 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
42 changes: 42 additions & 0 deletions payload/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
}

android {
namespace 'com.example.payload'
compileSdk 36

defaultConfig {
minSdk 24

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.17.0'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'com.google.android.material:material:1.13.0'
implementation 'org.jetbrains.kotlin:kotlin-parcelize-runtime:2.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
}
4 changes: 4 additions & 0 deletions payload/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
12 changes: 12 additions & 0 deletions payload/src/main/java/com/example/payload/Payload.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.payload

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class Payload(
val title: String,
val year: String,
val description: String
) : Parcelable

14 changes: 10 additions & 4 deletions receiver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id("io.gitlab.arturbosch.detekt")
id("kotlin-parcelize")
}

android {
compileSdk 34
compileSdk 36

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

Expand All @@ -30,10 +31,13 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'otus.gpb.homework.activities.receiver'

namespace "otus.gpb.homework.activities.receiver"

buildFeatures {
viewBinding true
}
buildToolsVersion '36.0.0'
}

detekt {
Expand All @@ -57,4 +61,6 @@ 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 'org.jetbrains.kotlin:kotlin-parcelize-runtime:2.2.20'
implementation project(':payload')
}
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="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
Expand Up @@ -2,11 +2,33 @@ package otus.gpb.homework.activities.receiver

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.IntentCompat
import android.widget.ImageView
import android.widget.TextView
import com.example.payload.Payload

class ReceiverActivity : AppCompatActivity() {

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

val payload: Payload? = IntentCompat.getParcelableExtra(intent, "intentPayload", Payload::class.java)

val imageViewer = findViewById<ImageView>(R.id.posterImageView)
val imageId = when (payload?.title) {
"Славные парни" -> R.drawable.niceguys
"Интерстеллар" -> R.drawable.interstellar
else -> 0
}

if( imageId > 0 ) {
imageViewer.setImageDrawable(AppCompatResources.getDrawable(this, imageId))
}

findViewById<TextView>(R.id.titleTextView).apply { text = payload?.title }
findViewById<TextView>(R.id.descriptionTextView).apply { text = payload?.description }
findViewById<TextView>(R.id.yearTextView).apply { text = payload?.year }
}
}
2 changes: 1 addition & 1 deletion receiver/src/main/res/layout/activity_receiver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ReceiverActivity">
tools:context="otus.gpb.homework.activities.receiver.ReceiverActivity">

<ImageView
android:id="@+id/posterImageView"
Expand Down
15 changes: 11 additions & 4 deletions sender/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
}

android {
compileSdk 34
compileSdk 36

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

Expand All @@ -29,15 +30,21 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'otus.gpb.homework.activities.receiver'

namespace "otus.gpb.homework.activities.sender"

buildFeatures {
viewBinding true
}
buildToolsVersion '36.0.0'
}

dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
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'
implementation 'org.jetbrains.kotlin:kotlin-parcelize-runtime:2.2.20'
implementation project(':payload')
}
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>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package otus.gpb.homework.activities.sender

import android.content.Intent
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 com.example.payload.Payload

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<Button>(R.id.button1).setOnClickListener {
val intent = openMap()
startActivity(intent)
}

findViewById<Button>(R.id.button2).setOnClickListener {
val intent = openMail()
startActivity(intent)
}

findViewById<Button>(R.id.button3).setOnClickListener {
val intent = openIntent()
startActivity(intent)
}
}

fun openMap() = Intent(
Intent.ACTION_VIEW,
Uri.parse("geo:0,0?z=30&q=Restaurants near Moscow, Russia")
).setPackage("com.google.android.apps.maps")

fun openMail() = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf("android@otus.ru"))
putExtra(Intent.EXTRA_SUBJECT, "Тестовое письмо в OTUS")
putExtra(Intent.EXTRA_TEXT, "Привет, OTUS! Как дела?")
}

fun openIntent(): Intent {
val intent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
addCategory(Intent.CATEGORY_DEFAULT)
putExtra("intentPayload", Payload("Славные парни", "2016", "Что бывает, когда напарником брутального костолома становится субтильный лопух? Наемный охранник Джексон Хили и частный детектив Холланд Марч вынуждены работать в паре, чтобы распутать плевое дело о пропавшей девушке, которое оборачивается преступлением века. Смогут ли парни разгадать сложный ребус, если у каждого из них – свои, весьма индивидуальные методы."))
}
return intent
}
}
48 changes: 48 additions & 0 deletions sender/src/main/res/layout/activity_sender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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/button1"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="100dp"
android:text="To Google Maps"
android:textAllCaps="false"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button2"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:text="Send Email"
android:textAllCaps="false"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button1" />

<Button
android:id="@+id/button3"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:text="Open Receiver"
android:textAllCaps="false"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2" />
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dependencyResolutionManagement {
rootProject.name = "Activities"
include ':sender'
include ':receiver'
include ':payload'