diff --git a/receiver/build.gradle b/receiver/build.gradle index 243c0925..5acc120a 100644 --- a/receiver/build.gradle +++ b/receiver/build.gradle @@ -1,60 +1,61 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id("io.gitlab.arturbosch.detekt") -} - -android { - compileSdk 34 - - defaultConfig { - applicationId "otus.gpb.homework.activities.receiver" - minSdk 23 - targetSdk 34 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - namespace 'otus.gpb.homework.activities.receiver' - buildFeatures { - viewBinding true - } -} - -detekt { - source = files("src/main/java", "src/main/kotlin") - config = files("$rootDir/config/detekt/detekt.yml") -} - -tasks.named("detekt").configure { - reports { - txt.required.set(true) - html.required.set(false) - md.required.set(false) - xml.required.set(false) - sarif.required.set(false) - html.outputLocation.set(file("build/reports/detekt/detekt.html")) - } -} - -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' +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id("io.gitlab.arturbosch.detekt") +} + +android { + compileSdk 35 + + defaultConfig { + applicationId "otus.gpb.homework.activities.receiver" + minSdk 23 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + namespace 'otus.gpb.homework.activities.receiver' + buildFeatures { + viewBinding true + } +} + +detekt { + source = files("src/main/java", "src/main/kotlin") + config = files("$rootDir/config/detekt/detekt.yml") +} + +tasks.named("detekt").configure { + reports { + txt.required.set(true) + html.required.set(false) + md.required.set(false) + xml.required.set(false) + sarif.required.set(false) + html.outputLocation.set(file("build/reports/detekt/detekt.html")) + } +} + +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.10.0' } \ No newline at end of file diff --git a/receiver/src/main/AndroidManifest.xml b/receiver/src/main/AndroidManifest.xml index e2f6ea6c..5e16edff 100644 --- a/receiver/src/main/AndroidManifest.xml +++ b/receiver/src/main/AndroidManifest.xml @@ -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" > + + + + + + + + \ No newline at end of file diff --git a/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt b/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt index b3fe360c..19609229 100644 --- a/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt +++ b/receiver/src/main/java/otus/gpb/homework/activities/receiver/ReceiverActivity.kt @@ -1,6 +1,9 @@ package otus.gpb.homework.activities.receiver +import android.graphics.drawable.Drawable import android.os.Bundle +import android.widget.ImageView +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class ReceiverActivity : AppCompatActivity() { @@ -8,5 +11,23 @@ class ReceiverActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_receiver) + + val filmTitle: TextView = findViewById(R.id.titleTextView) + filmTitle.text = intent.extras?.getString("title").orEmpty() + + val filmYear: TextView = findViewById(R.id.yearTextView) + filmYear.text = intent.extras?.getString("year").orEmpty() + + val filmDescription: TextView = findViewById(R.id.descriptionTextView) + filmDescription.text = intent.extras?.getString("description").orEmpty() + + val filmPosterView: ImageView = findViewById(R.id.posterImageView) + + var filmPicture: Drawable? = null + when (filmTitle.text) { + "Славные парни" -> filmPicture = getDrawable( R.drawable.niceguys ) + "Интерстеллар" -> filmPicture = getDrawable( R.drawable.interstellar ) + } + if( filmPicture != null ) filmPosterView.setImageDrawable( filmPicture ) } } diff --git a/receiver/src/main/res/layout/activity_receiver.xml b/receiver/src/main/res/layout/activity_receiver.xml index 6e89c012..3628c5bb 100644 --- a/receiver/src/main/res/layout/activity_receiver.xml +++ b/receiver/src/main/res/layout/activity_receiver.xml @@ -1,55 +1,55 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/sender/build.gradle b/sender/build.gradle index 9854ad15..373dc542 100644 --- a/sender/build.gradle +++ b/sender/build.gradle @@ -1,43 +1,43 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdk 34 - - defaultConfig { - applicationId "otus.gpb.homework.activities.sender" - minSdk 23 - targetSdk 34 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - namespace 'otus.gpb.homework.activities.receiver' - buildFeatures { - viewBinding true - } -} - -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' +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + compileSdk 35 + + defaultConfig { + applicationId "otus.gpb.homework.activities.sender" + minSdk 23 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + namespace 'otus.gpb.homework.activities.receiver' + buildFeatures { + viewBinding true + } +} + +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' } \ No newline at end of file diff --git a/sender/src/main/AndroidManifest.xml b/sender/src/main/AndroidManifest.xml index 1bddc002..9370855f 100644 --- a/sender/src/main/AndroidManifest.xml +++ b/sender/src/main/AndroidManifest.xml @@ -1,12 +1,22 @@ - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt b/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt new file mode 100644 index 00000000..4011e9bd --- /dev/null +++ b/sender/src/main/java/otus/gpb/homework/activities/sender/SenderActivity.kt @@ -0,0 +1,59 @@ +package otus.gpb.homework.activities.sender + +import android.content.Intent +import android.content.Intent.CATEGORY_DEFAULT +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 otus.gpb.homework.activities.receiver.R + + +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 + } + val mapButton: Button = findViewById(R.id.googleMapButton) + val mailButton: Button = findViewById(R.id.mailButton) + val recvButton: Button = findViewById(R.id.recvButton) + + mapButton.setOnClickListener{ + val gmmIntentUri = Uri.parse("geo:55.79912949569792, 37.61286149643574?q=restaurants") + val intentActivityGoMap = Intent( Intent.ACTION_VIEW, gmmIntentUri ) + intentActivityGoMap.setPackage("com.google.android.apps.maps") + startActivity( intentActivityGoMap ) + } + + mailButton.setOnClickListener{ + val intentActivityMail = Intent( Intent.ACTION_SENDTO ).apply { + data = Uri.parse("mailto:") + putExtra( Intent.EXTRA_EMAIL, arrayOf("masenko@pay-lab.ru") ) + putExtra(Intent.EXTRA_SUBJECT, "Test letter") + putExtra(Intent.EXTRA_TEXT, "Hello Otus!!!") + } + startActivity( intentActivityMail ) + } + + recvButton.setOnClickListener { + val intentActivityRecv = Intent(Intent.ACTION_SEND).apply { + setType("text/plain") + addCategory(Intent.CATEGORY_DEFAULT) + + putExtra("title", "Славные парни") + putExtra("year", "2016") + putExtra( "description", "Что бывает, когда напарником брутального костолома ...." ) + } + startActivity( intentActivityRecv ) + } + + } +} \ No newline at end of file diff --git a/sender/src/main/res/layout/activity_sender.xml b/sender/src/main/res/layout/activity_sender.xml new file mode 100644 index 00000000..525abd3a --- /dev/null +++ b/sender/src/main/res/layout/activity_sender.xml @@ -0,0 +1,42 @@ + + + +