Skip to content

Commit eb00b7d

Browse files
E.SalnikovСальников Евгений Владимирович
authored andcommitted
homework activity 02
1 parent 57f6b0d commit eb00b7d

File tree

9 files changed

+158
-18
lines changed

9 files changed

+158
-18
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id 'com.android.application' version '8.4.0' apply false
4-
id 'com.android.library' version '8.4.0' apply false
5-
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
6-
id "io.gitlab.arturbosch.detekt" version "1.21.0"
3+
id 'com.android.application' version '8.12.3' apply false
4+
id 'com.android.library' version '8.12.3' apply false
5+
id 'org.jetbrains.kotlin.android' version '2.2.20' apply false
6+
id "io.gitlab.arturbosch.detekt" version "1.23.8"
77
}
88

99
task clean(type: Delete) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sat Aug 27 13:57:30 MSK 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

receiver/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
android {
8-
compileSdk 34
8+
compileSdk 36
99

1010
defaultConfig {
1111
applicationId "otus.gpb.homework.activities.receiver"
@@ -53,8 +53,8 @@ tasks.named("detekt").configure {
5353
}
5454

5555
dependencies {
56-
implementation 'androidx.core:core-ktx:1.13.1'
57-
implementation 'androidx.appcompat:appcompat:1.6.1'
58-
implementation 'com.google.android.material:material:1.12.0'
59-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
56+
implementation 'androidx.core:core-ktx:1.17.0'
57+
implementation 'androidx.appcompat:appcompat:1.7.1'
58+
implementation 'com.google.android.material:material:1.13.0'
59+
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
6060
}

receiver/src/main/AndroidManifest.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
android:label="@string/app_name"
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
11-
android:theme="@style/Theme.Activities" />
11+
android:theme="@style/Theme.Activities">
12+
<activity
13+
android:name=".ReceiverActivity"
14+
android:exported="true">
15+
<intent-filter>
16+
<action android:name="android.intent.action.SEND" />
17+
<category android:name="android.intent.category.DEFAULT" />
18+
<data android:mimeType="text/plain"/>
19+
</intent-filter>
20+
</activity>
21+
</application>
1222

1323
</manifest>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
package otus.gpb.homework.activities.receiver
22

3+
import android.content.Context
4+
import android.graphics.drawable.Drawable
35
import android.os.Bundle
6+
import android.view.View
7+
import android.widget.ImageView
8+
import android.widget.TextView
49
import androidx.appcompat.app.AppCompatActivity
10+
import androidx.core.content.ContextCompat
511

612
class ReceiverActivity : AppCompatActivity() {
713

814
override fun onCreate(savedInstanceState: Bundle?) {
915
super.onCreate(savedInstanceState)
1016
setContentView(R.layout.activity_receiver)
17+
18+
intent?.extras?.let { defaultViewModelCreationExtras ->
19+
defaultViewModelCreationExtras.getString("title")?.let {
20+
findViewById<TextView>(R.id.titleTextView).text = it
21+
22+
when (it) {
23+
"interstellar" -> ContextCompat.getDrawable(this, R.drawable.interstellar)
24+
"niceguys" -> ContextCompat.getDrawable(this, R.drawable.niceguys)
25+
else -> null
26+
}?.let { drawable ->
27+
findViewById<ImageView>(R.id.posterImageView).setImageDrawable(drawable)
28+
} ?: findViewById<ImageView>(R.id.posterImageView).setVisibility(View.GONE)
29+
}
30+
defaultViewModelCreationExtras.getString("year")?.let {
31+
findViewById<TextView>(R.id.yearTextView).text = it
32+
}
33+
defaultViewModelCreationExtras.getString("description")?.let {
34+
findViewById<TextView>(R.id.descriptionTextView).text = it
35+
}
36+
37+
}
1138
}
1239
}

sender/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdk 34
7+
compileSdk 36
88

99
defaultConfig {
1010
applicationId "otus.gpb.homework.activities.sender"
1111
minSdk 23
12-
targetSdk 34
12+
targetSdk 36
1313
versionCode 1
1414
versionName "1.0"
1515

@@ -36,8 +36,9 @@ android {
3636
}
3737

3838
dependencies {
39-
implementation 'androidx.core:core-ktx:1.13.1'
40-
implementation 'androidx.appcompat:appcompat:1.6.1'
41-
implementation 'com.google.android.material:material:1.12.0'
42-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
39+
implementation 'androidx.core:core-ktx:1.17.0'
40+
implementation 'androidx.appcompat:appcompat:1.7.1'
41+
implementation 'com.google.android.material:material:1.13.0'
42+
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
43+
implementation 'androidx.activity:activity:1.11.0'
4344
}

sender/src/main/AndroidManifest.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
android:label="@string/app_name"
88
android:roundIcon="@mipmap/ic_launcher_round"
99
android:supportsRtl="true"
10-
android:theme="@style/Theme.Activities" />
10+
android:theme="@style/Theme.Activities">
11+
<activity
12+
android:name="otus.gpb.homework.activities.sender.SenderActivity"
13+
android:exported="true">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
1121

1222
</manifest>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package otus.gpb.homework.activities.sender
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import android.widget.Button
6+
import androidx.activity.enableEdgeToEdge
7+
import androidx.appcompat.app.AppCompatActivity
8+
import androidx.core.net.toUri
9+
import androidx.core.view.ViewCompat
10+
import androidx.core.view.WindowInsetsCompat
11+
import otus.gpb.homework.activities.receiver.R
12+
13+
class SenderActivity : AppCompatActivity() {
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
enableEdgeToEdge()
17+
setContentView(R.layout.sender_activity)
18+
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
19+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
20+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
21+
insets
22+
}
23+
24+
findViewById<Button>(R.id.buttonMaps).setOnClickListener {
25+
val intent = Intent(Intent.ACTION_VIEW, "geo:0,0?q=restaurants".toUri())
26+
intent.setPackage("com.google.android.apps.maps")
27+
startActivity(intent)
28+
}
29+
30+
findViewById<Button>(R.id.buttonEmail).setOnClickListener {
31+
val intent = Intent(Intent.ACTION_SENDTO, "mailto:android@otus.ru".toUri())
32+
intent.putExtra(Intent.EXTRA_SUBJECT, "some subject")
33+
intent.putExtra(Intent.EXTRA_TEXT, "some email text")
34+
startActivity(intent)
35+
}
36+
37+
findViewById<Button>(R.id.buttonReceiver).setOnClickListener {
38+
val intent = Intent(Intent.ACTION_SEND)
39+
intent.type = "text/plain"
40+
intent.addCategory(Intent.CATEGORY_DEFAULT)
41+
intent.putExtra("title", "interstellar")
42+
intent.putExtra("year", "2025")
43+
intent.putExtra("description", "Трудный был год")
44+
startActivity(intent)
45+
}
46+
}
47+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:id="@+id/main"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context="otus.gpb.homework.activities.sender.SenderActivity">
9+
10+
<Button
11+
android:id="@+id/buttonMaps"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:text="To Google Maps"
15+
app:layout_constraintBottom_toBottomOf="parent"
16+
app:layout_constraintEnd_toEndOf="parent"
17+
app:layout_constraintHorizontal_bias="0.5"
18+
app:layout_constraintStart_toStartOf="parent"
19+
app:layout_constraintTop_toTopOf="parent"
20+
app:layout_constraintVertical_bias="0.1" />
21+
22+
<Button
23+
android:id="@+id/buttonEmail"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:text="Send Email"
27+
app:layout_constraintBottom_toBottomOf="parent"
28+
app:layout_constraintEnd_toEndOf="parent"
29+
app:layout_constraintHorizontal_bias="0.497"
30+
app:layout_constraintStart_toStartOf="parent"
31+
app:layout_constraintTop_toTopOf="parent"
32+
app:layout_constraintVertical_bias="0.3" />
33+
34+
<Button
35+
android:id="@+id/buttonReceiver"
36+
android:layout_width="wrap_content"
37+
android:layout_height="wrap_content"
38+
android:text="Open Receiver"
39+
app:layout_constraintBottom_toBottomOf="parent"
40+
app:layout_constraintEnd_toEndOf="parent"
41+
app:layout_constraintHorizontal_bias="0.497"
42+
app:layout_constraintStart_toStartOf="parent"
43+
app:layout_constraintTop_toTopOf="parent"
44+
app:layout_constraintVertical_bias="0.5" />
45+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)