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
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// 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 "io.gitlab.arturbosch.detekt" version "1.21.0"
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.20' apply false
id "io.gitlab.arturbosch.detekt" version "1.23.8"
}

task clean(type: Delete) {
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
10 changes: 5 additions & 5 deletions receiver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
compileSdk 34
compileSdk 36

defaultConfig {
applicationId "otus.gpb.homework.activities.receiver"
Expand Down Expand Up @@ -53,8 +53,8 @@ tasks.named("detekt").configure {
}

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.core:core-ktx:1.17.0'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'com.google.android.material:material:1.13.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
}
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=".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,39 @@
package otus.gpb.homework.activities.receiver

import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat

class ReceiverActivity : AppCompatActivity() {

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

intent?.extras?.let { defaultViewModelCreationExtras ->
defaultViewModelCreationExtras.getString("title")?.let {
findViewById<TextView>(R.id.titleTextView).text = it

when (it) {
"Интерстеллар" -> ContextCompat.getDrawable(this, R.drawable.interstellar)
"Славные парни" -> ContextCompat.getDrawable(this, R.drawable.niceguys)
else -> null
}?.let { drawable ->
findViewById<ImageView>(R.id.posterImageView).setImageDrawable(drawable)
} ?: findViewById<ImageView>(R.id.posterImageView).setVisibility(View.GONE)
}
defaultViewModelCreationExtras.getString("year")?.let {
findViewById<TextView>(R.id.yearTextView).text = it
}
defaultViewModelCreationExtras.getString("description")?.let {
findViewById<TextView>(R.id.descriptionTextView).text = it
}

}
}
}
13 changes: 7 additions & 6 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 All @@ -36,8 +36,9 @@ android {
}

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.core:core-ktx:1.17.0'
implementation 'androidx.appcompat:appcompat:1.7.1'
implementation 'com.google.android.material:material:1.13.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
implementation 'androidx.activity:activity:1.11.0'
}
12 changes: 11 additions & 1 deletion sender/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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.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,47 @@
package otus.gpb.homework.activities.sender

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import otus.gpb.homework.activities.receiver.R

class SenderActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.sender_activity)
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.buttonMaps).setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, "geo:0,0?q=restaurants".toUri())
intent.setPackage("com.google.android.apps.maps")
startActivity(intent)
}

findViewById<Button>(R.id.buttonEmail).setOnClickListener {
val intent = Intent(Intent.ACTION_SENDTO, "mailto:android@otus.ru".toUri())
intent.putExtra(Intent.EXTRA_SUBJECT, "some subject")
intent.putExtra(Intent.EXTRA_TEXT, "some email text")
startActivity(intent)
}

findViewById<Button>(R.id.buttonReceiver).setOnClickListener {
val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.putExtra("title", "Интерстеллар")
intent.putExtra("year", "2014")
intent.putExtra("description", "Когда засуха, пыльные бури и вымирание растений приводят человечество к продовольственному кризису, коллектив исследователей и учёных отправляется сквозь червоточину (которая предположительно соединяет области пространства-времени через большое расстояние) в путешествие, чтобы превзойти прежние ограничения для космических путешествий человека и найти планету с подходящими для человечества условиями.")
startActivity(intent)
}
}
}
45 changes: 45 additions & 0 deletions sender/src/main/res/layout/sender_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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/buttonMaps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To Google Maps"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.1" />

<Button
android:id="@+id/buttonEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Email"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />

<Button
android:id="@+id/buttonReceiver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open Receiver"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>