From 8f7bf548b32b64ed7a6ecc9666ee0eb19c6a1003 Mon Sep 17 00:00:00 2001 From: Andrey Limasov Date: Wed, 13 Nov 2024 08:20:09 +0300 Subject: [PATCH] Template initial state --- app/build.gradle.kts | 4 ++ app/src/main/AndroidManifest.xml | 40 +++++++++----- .../java/ru/myitschool/work/MainActivity.java | 55 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 16 ++++++ app/src/main/res/layout/content_main.xml | 21 +++++++ app/src/main/res/values/strings.xml | 3 +- 6 files changed, 123 insertions(+), 16 deletions(-) create mode 100644 app/src/main/java/ru/myitschool/work/MainActivity.java create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/content_main.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8c899db..bc0d6df 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -32,6 +32,10 @@ android { } dependencies { + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("com.google.android.material:material:1.12.0") + implementation("androidx.activity:activity:1.9.3") + implementation("androidx.constraintlayout:constraintlayout:2.2.0") defaultLibrary() } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9ee5c40..b1cad16 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,16 +1,26 @@ - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ru/myitschool/work/MainActivity.java b/app/src/main/java/ru/myitschool/work/MainActivity.java new file mode 100644 index 0000000..05b8fd1 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/MainActivity.java @@ -0,0 +1,55 @@ +package ru.myitschool.work; + +import static java.util.Map.entry; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AppCompatActivity; + +import java.util.Map; + +import ru.myitschool.work.databinding.ActivityMainBinding; + +@RequiresApi(api = Build.VERSION_CODES.TIRAMISU) +public class MainActivity extends AppCompatActivity { + + final static Map CodelabActionsMap = Map.ofEntries( + entry(Intent.ACTION_AIRPLANE_MODE_CHANGED, "ACTION_AIRPLANE_MODE_CHANGED"), + entry(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED, "ACTION_APPLICATION_RESTRICTIONS_CHANGED"), + entry(Intent.ACTION_APPLICATION_LOCALE_CHANGED, "ACTION_APPLICATION_LOCALE_CHANGED"), + entry(Intent.ACTION_ASSIST, "ACTION_ASSIST"), + entry(Intent.ACTION_BATTERY_CHANGED, "ACTION_BATTERY_CHANGED"), + entry(Intent.ACTION_BATTERY_LOW, "ACTION_BATTERY_LOW"), + entry(Intent.ACTION_BATTERY_OKAY, "ACTION_BATTERY_OKAY"), + entry(Intent.ACTION_CALL, "ACTION_CALL"), + entry(Intent.ACTION_DATE_CHANGED, "ACTION_DATE_CHANGED"), + entry(Intent.ACTION_DEFAULT, "ACTION_DEFAULT"), + entry(Intent.ACTION_HEADSET_PLUG, "ACTION_HEADSET_PLUG"), + entry(Intent.ACTION_LOCALE_CHANGED, "ACTION_LOCALE_CHANGED"), + entry(Intent.ACTION_TIME_TICK, "ACTION_TIME_TICK") + ); + + ActivityMainBinding ui; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ui = ActivityMainBinding.inflate(getLayoutInflater()); + setContentView(ui.getRoot()); + } + + public BroadcastReceiver makeBroadcastReceiver() { + return new BroadcastReceiver() { + public void onReceive(Context context, Intent intent) { + var text = CodelabActionsMap.get(intent.getAction()); + if (text != null) ui.content.statusText.setText(text); + } + }; + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..4e0cd4e --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..1b168e7 --- /dev/null +++ b/app/src/main/res/layout/content_main.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96034ac..1482b83 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ - Work + Созерцание + Ожидание… \ No newline at end of file