From 1463d9e83f463c41efafaf2162b14c40a0a6b9b5 Mon Sep 17 00:00:00 2001 From: Daria Mandziuk Date: Wed, 19 Jul 2023 13:39:47 +0400 Subject: [PATCH 1/2] add realisation activity A, B, C, D --- .gitignore | 2 +- README.md | 6 - app/.gitignore | 3 +- app/build.gradle | 7 +- .../otus/otusdemo/ExampleInstrumentedTest.kt | 24 +++ app/src/main/AndroidManifest.xml | 41 +++++- .../main/java/ru/otus/otusdemo/ActivityA.kt | 27 ++++ .../main/java/ru/otus/otusdemo/ActivityB.kt | 26 ++++ .../main/java/ru/otus/otusdemo/ActivityC.kt | 50 +++++++ .../main/java/ru/otus/otusdemo/ActivityD.kt | 30 ++++ .../java/ru/otus/otusdemo/MainActivity.kt | 53 +++++++ .../java/ru/otus/otusdemo/OtusApplication.kt | 14 ++ .../java/ru/otus/otusdemo/SecondActivity.kt | 30 ++++ .../ContractMainActivityAndSecondActivity.kt | 24 +++ .../otusdemo/examples/SecondLessonExample.kt | 138 ++++++++++++++++++ .../otusdemo/examples/ThirdLessonExample.kt | 126 ++++++++++++++++ app/src/main/res/drawable/single_instance.png | Bin 0 -> 255105 bytes app/src/main/res/drawable/single_task.png | Bin 0 -> 192863 bytes app/src/main/res/drawable/single_top.png | Bin 0 -> 163006 bytes .../res/drawable/standart_launch_mode.png | Bin 0 -> 150309 bytes app/src/main/res/layout/activity_a.xml | 19 +++ app/src/main/res/layout/activity_b.xml | 19 +++ app/src/main/res/layout/activity_c.xml | 59 ++++++++ app/src/main/res/layout/activity_d.xml | 19 +++ app/src/main/res/layout/activity_main.xml | 28 ++++ app/src/main/res/layout/activity_second.xml | 18 +++ app/src/main/res/values-night/themes.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/values/themes.xml | 2 +- .../java/ru/otus/otusdemo/ExampleUnitTest.kt | 17 +++ build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 +- 33 files changed, 773 insertions(+), 19 deletions(-) delete mode 100644 README.md create mode 100644 app/src/androidTest/java/ru/otus/otusdemo/ExampleInstrumentedTest.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/ActivityA.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/ActivityB.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/ActivityC.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/ActivityD.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/MainActivity.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/OtusApplication.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/SecondActivity.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/examples/ContractMainActivityAndSecondActivity.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/examples/SecondLessonExample.kt create mode 100644 app/src/main/java/ru/otus/otusdemo/examples/ThirdLessonExample.kt create mode 100644 app/src/main/res/drawable/single_instance.png create mode 100644 app/src/main/res/drawable/single_task.png create mode 100644 app/src/main/res/drawable/single_top.png create mode 100644 app/src/main/res/drawable/standart_launch_mode.png create mode 100644 app/src/main/res/layout/activity_a.xml create mode 100644 app/src/main/res/layout/activity_b.xml create mode 100644 app/src/main/res/layout/activity_c.xml create mode 100644 app/src/main/res/layout/activity_d.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/activity_second.xml create mode 100644 app/src/test/java/ru/otus/otusdemo/ExampleUnitTest.kt diff --git a/.gitignore b/.gitignore index a9a7031..2d34da4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,4 @@ run.sh *.aab output-metadata.json /build.properties -*.hprof \ No newline at end of file +*.hprof diff --git a/README.md b/README.md deleted file mode 100644 index 6b5a493..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Activities #1 - -Домашняя работа к лекции **Activities #1**. В ней мы научимся работать с лаунч-модами и флагами запуска активити. - -Задание лежит здесь: -https://kazakovanton.notion.site/Activity-1-Homework-2826d9a095ce437ea9d9cf49b8cd34c1 \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index 42afabf..1571bfe 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,2 @@ -/build \ No newline at end of file +/build +/.gradle/ diff --git a/app/build.gradle b/app/build.gradle index 0579b10..4049c1b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' + id 'kotlin-parcelize' } android { @@ -35,4 +36,8 @@ dependencies { implementation 'androidx.core:core-ktx:1.8.0' implementation 'androidx.appcompat:appcompat:1.5.0' implementation 'com.google.android.material:material:1.6.1' -} \ No newline at end of file + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} diff --git a/app/src/androidTest/java/ru/otus/otusdemo/ExampleInstrumentedTest.kt b/app/src/androidTest/java/ru/otus/otusdemo/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..20c1fb7 --- /dev/null +++ b/app/src/androidTest/java/ru/otus/otusdemo/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package ru.otus.otusdemo + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("ru.otus.otusdemo", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f318e6c..a92d480 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,9 +1,10 @@ + package="ru.otus.otusdemo"> + android:theme="@style/Theme.OtusDemo" + tools:targetApi="31"> + + + + + + - \ No newline at end of file + + + + + + + + + diff --git a/app/src/main/java/ru/otus/otusdemo/ActivityA.kt b/app/src/main/java/ru/otus/otusdemo/ActivityA.kt new file mode 100644 index 0000000..deb179c --- /dev/null +++ b/app/src/main/java/ru/otus/otusdemo/ActivityA.kt @@ -0,0 +1,27 @@ +package ru.otus.otusdemo + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.Button +import android.widget.Toast + +class ActivityA : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_a) + + val button = findViewById