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: 3 additions & 1 deletion app/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"
Expand Down Expand Up @@ -56,4 +56,6 @@ 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.activity:activity:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
}
25 changes: 24 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Activities"
tools:targetApi="31" />
tools:targetApi="31">
<activity
android:name=".ActivityD"
android:exported="false"
android:taskAffinity=".AffinityB" />
<activity
android:name=".ActivityC"
android:exported="false"
android:taskAffinity=".AffinityB" />
<activity
android:name=".ActivityB"
android:exported="false"
android:launchMode="singleTask"
android:taskAffinity=".AffinityB" />
<activity
android:name=".ActivityA"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
29 changes: 29 additions & 0 deletions app/src/main/java/otus/gpb/homework/activities/ActivityA.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package otus.gpb.homework.activities

import android.content.Intent
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

class ActivityA : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_a)
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 btnOpenActivityB = findViewById<Button>(R.id.btn_open_ActivityB)
btnOpenActivityB.setOnClickListener {
val intent = Intent(this, ActivityB::class.java)
startActivity(intent)
}

}
}
29 changes: 29 additions & 0 deletions app/src/main/java/otus/gpb/homework/activities/ActivityB.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package otus.gpb.homework.activities

import android.content.Intent
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

class ActivityB : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_b)
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 btnOpenActivityC = findViewById<Button>(R.id.btn_open_ActivityC)
btnOpenActivityC.setOnClickListener {
val intent = Intent(this, ActivityC::class.java)
startActivity(intent)
}

}
}
47 changes: 47 additions & 0 deletions app/src/main/java/otus/gpb/homework/activities/ActivityC.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package otus.gpb.homework.activities

import android.content.Intent
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

class ActivityC : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_c)
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 btnOpenActivityA = findViewById<Button>(R.id.btn_open_ActivityA)
btnOpenActivityA.setOnClickListener {
val intent = Intent(this, ActivityA::class.java)
startActivity(intent)
}

val btnOpenActivityD = findViewById<Button>(R.id.btn_open_ActivityD)
btnOpenActivityD.setOnClickListener {
val intent = Intent(this, ActivityD::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent)
}

val btnCloseActivityC = findViewById<Button>(R.id.btn_close_ActivityC)
btnCloseActivityC.setOnClickListener {
finish()
}

val btnCloseStack = findViewById<Button>(R.id.btn_close_stack)
btnCloseStack.setOnClickListener {
finishAffinity()
}

}
}
20 changes: 20 additions & 0 deletions app/src/main/java/otus/gpb/homework/activities/ActivityD.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package otus.gpb.homework.activities

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class ActivityD : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_d)
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
}
}
}
21 changes: 21 additions & 0 deletions app/src/main/res/layout/activity_a.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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"
android:background="#f44336"
tools:context=".ActivityA">

<Button
android:id="@+id/btn_open_ActivityB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_open_activityb"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
21 changes: 21 additions & 0 deletions app/src/main/res/layout/activity_b.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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"
android:background="#4caf50"
tools:context=".ActivityB">

<Button
android:id="@+id/btn_open_ActivityC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_open_activityc"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
51 changes: 51 additions & 0 deletions app/src/main/res/layout/activity_c.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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"
android:background="#2196f3"
tools:context=".ActivityC">

<Button
android:id="@+id/btn_open_ActivityA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_open_activitya"
app:layout_constraintBottom_toTopOf="@id/btn_open_ActivityD"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_open_ActivityD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_open_activityd"
app:layout_constraintBottom_toTopOf="@id/btn_close_ActivityC"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_open_ActivityA" />

<Button
android:id="@+id/btn_close_ActivityC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_close_activityc"
app:layout_constraintBottom_toTopOf="@id/btn_close_stack"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_open_ActivityD" />

<Button
android:id="@+id/btn_close_stack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_close_stack"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_close_ActivityC" />

</androidx.constraintlayout.widget.ConstraintLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_d.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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"
android:background="#ffeb3b"
tools:context=".ActivityD">

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<resources>
<string name="app_name">Activities</string>
<string name="btn_open_activityb">Open ActivityB</string>
<string name="btn_open_activityc">Open ActivityC</string>
<string name="btn_open_activitya">Open ActivityA</string>
<string name="btn_close_activityc">Close ActivityC</string>
<string name="btn_open_activityd">Open ActivityD</string>
<string name="btn_close_stack">Close Stack</string>
</resources>
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.11.2' apply false
id 'com.android.library' version '8.11.2' 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