-
Notifications
You must be signed in to change notification settings - Fork 100
ДЗ по Activity 01 #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mahonin-ms
wants to merge
3
commits into
Android-Developer-Basic:homework/activity_01
Choose a base branch
from
mahonin-ms:activity_01
base: homework/activity_01
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ДЗ по Activity 01 #224
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/otus/gpb/homework/activities/ActivityA.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import android.view.ViewGroup | ||
| 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(), BaseComponentsI { | ||
|
|
||
| override lateinit var buttonOpenView: Button | ||
| 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 | ||
| } | ||
|
|
||
| getSupportActionBar()?.setTitle("Activity A") | ||
|
|
||
| buttonOpenView = findViewById<ViewGroup>(R.id.base).findViewById(R.id.button) | ||
| buttonOpenView.text = resources.getStringArray(R.array.open_buttons)[1] // Open Activity B | ||
| buttonOpenView.setOnClickListener { | ||
| startActivity( Intent(this, ActivityB::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) | ||
| } | ||
| } | ||
|
|
||
| override fun onNewIntent(intent: Intent) { | ||
| super.onNewIntent(intent) | ||
| Log.d("ActivityA", "get ActivityA and call callback onNewIntent") | ||
| } | ||
|
|
||
| } | ||
32 changes: 32 additions & 0 deletions
32
app/src/main/java/otus/gpb/homework/activities/ActivityB.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.view.ViewGroup | ||
| 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(), BaseComponentsI { | ||
| override lateinit var buttonOpenView: Button | ||
| 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 | ||
| } | ||
|
|
||
| getSupportActionBar()?.setTitle("Activity B") | ||
|
|
||
| buttonOpenView = findViewById<ViewGroup>(R.id.base).findViewById(R.id.button) | ||
| buttonOpenView.text = resources.getStringArray(R.array.open_buttons)[2] // Open Activity C | ||
| buttonOpenView.setOnClickListener { | ||
| startActivity( Intent(this, ActivityC::class.java)) | ||
| } | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
app/src/main/java/otus/gpb/homework/activities/ActivityC.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.view.ViewGroup | ||
| 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() { | ||
| private lateinit var btn1:Button // Open A | ||
| private lateinit var btn2:Button // Open D | ||
| private lateinit var btn3:Button // Close C | ||
| 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 | ||
| } | ||
|
|
||
| getSupportActionBar()?.setTitle("Activity C") | ||
|
|
||
| btn1 = findViewById<ViewGroup>(R.id.base_1).findViewById(R.id.button) | ||
| btn1.text = resources.getStringArray(R.array.open_buttons)[0] // Open Activity A | ||
| btn1.setOnClickListener { | ||
| val intent = Intent(this, ActivityA::class.java) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) | ||
| startActivity(intent) | ||
| } | ||
|
|
||
| btn2 = findViewById<ViewGroup>(R.id.base_2).findViewById(R.id.button) | ||
| btn2.text = resources.getStringArray(R.array.open_buttons)[3] // Open Activity D | ||
| btn2.setOnClickListener { | ||
| val intent = Intent(this, ActivityD::class.java) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) | ||
| startActivity(intent) | ||
| } | ||
|
|
||
| btn3 = findViewById<ViewGroup>(R.id.base_3).findViewById(R.id.button) | ||
| btn3.text = resources.getStringArray(R.array.close_buttons)[0] // Close Activity C | ||
| btn3.setOnClickListener { finish() } | ||
|
|
||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/otus/gpb/homework/activities/ActivityD.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.ViewGroup | ||
| import android.widget.Button | ||
| import androidx.activity.enableEdgeToEdge | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.core.view.ViewCompat | ||
| import androidx.core.view.WindowInsetsCompat | ||
|
|
||
| class ActivityD : AppCompatActivity(), BaseComponentsI { | ||
| override lateinit var buttonOpenView: Button | ||
| 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 | ||
| } | ||
|
|
||
| getSupportActionBar()?.setTitle("Activity D") | ||
|
|
||
| buttonOpenView = findViewById<ViewGroup>(R.id.base).findViewById(R.id.button) | ||
| buttonOpenView.text = resources.getStringArray(R.array.close_buttons)[1] // Close Stack | ||
| buttonOpenView.setOnClickListener { | ||
| finishAffinity() | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/otus/gpb/homework/activities/BaseComponentsI.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.widget.Button | ||
|
|
||
|
|
||
| interface BaseComponentsI { | ||
| val buttonOpenView: Button | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/main" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| tools:context=".ActivityA" | ||
| android:background="#f44336"> | ||
|
|
||
| <include layout="@layout/base" | ||
| android:id="@+id/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
|
|
||
| </LinearLayout > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/main" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| tools:context=".ActivityB" | ||
| android:background="#4caf50"> | ||
|
|
||
| <include layout="@layout/base" | ||
| android:id="@+id/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/main" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:orientation="vertical" | ||
| tools:context=".ActivityC" | ||
| android:background="#2196f3"> | ||
|
|
||
| <include | ||
| android:id="@+id/base_1" | ||
| layout="@layout/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| <include | ||
| android:id="@+id/base_2" | ||
| layout="@layout/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| <include | ||
| android:id="@+id/base_3" | ||
| layout="@layout/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/main" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| tools:context=".ActivityD" | ||
| android:background="#ffeb3b"> | ||
|
|
||
| <include layout="@layout/base" | ||
| android:id="@+id/base" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
|
|
||
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:orientation="vertical" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent"> | ||
|
|
||
|
|
||
| <Button | ||
| android:id="@+id/button" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:text="Button" | ||
| android:layout_marginTop="128dp" > | ||
| </Button> | ||
|
|
||
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| <resources> | ||
| <string name="app_name">Activities</string> | ||
| <string-array name="open_buttons"> | ||
| <item>Open Activity A</item> | ||
| <item>Open Activity B</item> | ||
| <item>Open Activity C</item> | ||
| <item>Open Activity D</item> | ||
| </string-array> | ||
| <string-array name="close_buttons"> | ||
| <item>Close Activity C</item> | ||
| <item>Close Stack</item> | ||
| </string-array> | ||
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #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.6-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip | ||
| distributionPath=wrapper/dists | ||
| zipStorePath=wrapper/dists | ||
| zipStoreBase=GRADLE_USER_HOME |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mahonin-ms, тут надо еще подумать.
Задание:
А у вас и режим запуска стандартный и affinity нету - откроется в том же стеке