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.13.0' apply false
id 'com.android.library' version '8.13.0' 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
13 changes: 11 additions & 2 deletions receiver/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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=".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,39 @@ package otus.gpb.homework.activities.receiver

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


class ReceiverActivity : AppCompatActivity() {

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

val title = intent.getStringExtra("title")
val year = intent.getStringExtra("year")
val description = intent.getStringExtra("description")

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

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

when (title) {
"Славные парни" -> {
posterImageView.setImageDrawable(getDrawable(R.drawable.niceguys))
}
"Интерстеллар" -> {
posterImageView.setImageDrawable(getDrawable(R.drawable.interstellar))
}
else -> {
posterImageView.setImageDrawable(null)
}
}
}
}
8 changes: 5 additions & 3 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 35

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

Expand Down Expand Up @@ -40,4 +40,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 'androidx.compose.material3:material3:1.3.2'
implementation 'androidx.wear.compose:compose-material:1.5.1'
}
6 changes: 5 additions & 1 deletion sender/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
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"/>
</application>

</manifest>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package otus.gpb.homework.activities.sender

data class Payload(
val title: String,
val year: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package otus.gpb.homework.activities.sender

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

class SenderActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sender)
val buttonMaps = findViewById<Button>(R.id.ButtonMaps)
val buttonEmail = findViewById<Button>(R.id.buttonEmail)
val buttonReceiver = findViewById<Button>(R.id.buttonReceiver)

buttonMaps.setOnClickListener {
val restIntent = "geo:0,0?q=Рестораны".toUri()
val mapIntent = Intent(Intent.ACTION_VIEW, restIntent)
mapIntent.setPackage("com.google.android.apps.maps")
startActivity(mapIntent)
}

buttonEmail.setOnClickListener {
val emailIntent = Intent(Intent.ACTION_SENDTO).apply {
data = "mailto:help@otus.ru".toUri()
putExtra(Intent.EXTRA_SUBJECT, "Домашнее задание")
putExtra(Intent.EXTRA_TEXT, "Помогите с домашним заданием, я не справляюсь")
}
startActivity(emailIntent)
}

buttonReceiver.setOnClickListener {
val input = assets.open("payload.txt")
val lines = input.bufferedReader().readLines()

val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
addCategory(Intent.CATEGORY_DEFAULT)

putExtra("title", lines.getOrNull(0) ?.substringAfter("title:")?.trim() ?: "Unknown title")
putExtra("year", lines.getOrNull(1) ?.substringAfter("year:")?.trim() ?: "Unknown Year")
putExtra("description", lines.getOrNull(2) ?.substringAfter("description:")?.trim() ?: "No description")
}
startActivity(sendIntent)
}

}
}
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_gooogle_maps">To Gooogle Maps</string>
<string name="send_email">Send Email</string>
<string name="open_receiver" />
</resources>