diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/app/build.gradle b/app/build.gradle index 93d31ce..7cbe554 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -40,4 +40,5 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation("io.coil-kt:coil:2.0.0-rc03") } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a551aff..9335522 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + + diff --git a/app/src/main/java/com/github/krottv/tmstemp/MainActivity.kt b/app/src/main/java/com/github/krottv/tmstemp/MainActivity.kt index 8952f64..256c610 100644 --- a/app/src/main/java/com/github/krottv/tmstemp/MainActivity.kt +++ b/app/src/main/java/com/github/krottv/tmstemp/MainActivity.kt @@ -2,10 +2,98 @@ package com.github.krottv.tmstemp import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.view.animation.Animation +import android.view.animation.AnimationUtils +import android.widget.ImageView +import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout +import coil.load +import coil.transform.CircleCropTransformation class MainActivity : AppCompatActivity() { + + private lateinit var img1: ImageView + private lateinit var img2: ImageView + private lateinit var img3: ImageView + private lateinit var lay1: ConstraintLayout + private lateinit var lay2: ConstraintLayout + private lateinit var lay3: ConstraintLayout + private lateinit var mTxt1: TextView + private lateinit var mTxt2: TextView + private lateinit var mTxt3: TextView + private lateinit var sTxt1: TextView + private lateinit var sTxt2: TextView + private lateinit var sTxt3: TextView + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + + img1 = findViewById(R.id.img1) + img2 = findViewById(R.id.img2) + img3 = findViewById(R.id.img3) + + val img1Link = "https://images.unsplash.com/photo-1568127861543-b0c0696c735f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=470&q=80" + val img2Link = "https://images.unsplash.com/photo-1563452965085-2e77e5bf2607?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=470&q=80" + val img3Link = "https://images.unsplash.com/photo-1575439047055-83e6174df3b9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=470&q=80" + + img1.load(img1Link){ + crossfade(true) + placeholder(R.drawable.ic_launcher_foreground) + transformations(CircleCropTransformation()) + } + img2.load(img2Link){ + crossfade(true) + placeholder(R.drawable.ic_launcher_foreground) + transformations(CircleCropTransformation()) + } + img3.load(img3Link){ + crossfade(true) + placeholder(R.drawable.ic_launcher_foreground) + transformations(CircleCropTransformation()) + } + + lay1 = findViewById(R.id.constr_1) + lay2 = findViewById(R.id.constr_2) + lay3 = findViewById(R.id.constr_3) + + mTxt1 = findViewById(R.id.m_txt_1) + mTxt1.setText(R.string.m_txt_1) + + mTxt2 = findViewById(R.id.m_txt_2) + mTxt2.setText(R.string.m_txt_2) + + mTxt3 = findViewById(R.id.m_txt_3) + mTxt3.setText(R.string.m_txt_3) + + sTxt1 = findViewById(R.id.s_txt_1) + sTxt1.setText(R.string.some_txt) + + sTxt2 = findViewById(R.id.s_txt_2) + sTxt2.setText(R.string.some_txt) + + sTxt3 = findViewById(R.id.s_txt_3) + sTxt3.setText(R.string.some_txt) + + val scaleAnim: Animation = AnimationUtils.loadAnimation(this, R.anim.scale_infinite) + lay1.animation = scaleAnim + + val alphaAnim: Animation = AnimationUtils.loadAnimation(this, R.anim.alpha_infinite) + lay3.animation = alphaAnim + + lay1.setOnClickListener{ + val intent = SecondScreenActivity.newIntent(this@MainActivity, mTxt1.text.toString(), sTxt1.text.toString(), img1Link) + startActivity(intent) + } + + lay2.setOnClickListener{ + val intent = SecondScreenActivity.newIntent(this@MainActivity, mTxt2.text.toString(), sTxt2.text.toString(), img2Link) + startActivity(intent) + } + + lay3.setOnClickListener{ + val intent = SecondScreenActivity.newIntent(this@MainActivity, mTxt3.text.toString(), sTxt3.text.toString(), img3Link) + startActivity(intent) + } } } \ No newline at end of file diff --git a/app/src/main/java/com/github/krottv/tmstemp/SecondScreenActivity.kt b/app/src/main/java/com/github/krottv/tmstemp/SecondScreenActivity.kt new file mode 100644 index 0000000..2337cba --- /dev/null +++ b/app/src/main/java/com/github/krottv/tmstemp/SecondScreenActivity.kt @@ -0,0 +1,73 @@ +package com.github.krottv.tmstemp + +import android.app.Activity +import android.content.Context +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.animation.AccelerateDecelerateInterpolator +import android.view.animation.Animation +import android.view.animation.AnimationUtils +import android.view.animation.CycleInterpolator +import android.widget.Button +import android.widget.ImageButton +import android.widget.ImageView +import android.widget.TextView +import coil.load + +private const val EXTRA_MAIN_TEXT = "main txt" +private const val EXTRA_SUB_TEXT = "sub txt" +private const val EXTRA_IMAGE_LINK = "img link" + +class SecondScreenActivity : AppCompatActivity() { + + private lateinit var mainText: TextView + private lateinit var subText: TextView + private lateinit var img: ImageView + private lateinit var crossButton: ImageButton + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_second_screen) + + mainText = findViewById(R.id.txt_ss_m) + val mTxt = intent.getStringExtra(EXTRA_MAIN_TEXT) + if (mTxt != null) { + mainText.setText(mTxt) + } + + subText = findViewById(R.id.txt_ss_s) + val sTxt = intent.getStringExtra(EXTRA_SUB_TEXT) + if (sTxt != null){ + subText.setText(sTxt) + } + + img = findViewById(R.id.img_ss) + val imgLink = intent.getStringExtra(EXTRA_IMAGE_LINK) + if (imgLink != null){ + img.load(imgLink) + } + + crossButton = findViewById(R.id.cross_button) + val crossAnimate: Animation = AnimationUtils.loadAnimation(this, R.anim.rotation) + crossButton.animation = crossAnimate +// crossButton.animate().apply { +// rotation(3600F) +// duration = 7500 +// interpolator = AccelerateDecelerateInterpolator() +// }.start() + crossButton.setOnClickListener{ + finish() + } + } + + companion object{ + fun newIntent(context: Context, mainText: String, subText: String, link: String): Intent{ + return Intent(context, SecondScreenActivity::class.java).apply { + putExtra(EXTRA_MAIN_TEXT, mainText) + putExtra(EXTRA_SUB_TEXT, subText) + putExtra(EXTRA_IMAGE_LINK, link) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/anim/alpha_infinite.xml b/app/src/main/res/anim/alpha_infinite.xml new file mode 100644 index 0000000..60f0929 --- /dev/null +++ b/app/src/main/res/anim/alpha_infinite.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/rotation.xml b/app/src/main/res/anim/rotation.xml new file mode 100644 index 0000000..4714858 --- /dev/null +++ b/app/src/main/res/anim/rotation.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/scale_infinite.xml b/app/src/main/res/anim/scale_infinite.xml new file mode 100644 index 0000000..7d4f3b9 --- /dev/null +++ b/app/src/main/res/anim/scale_infinite.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_close.xml b/app/src/main/res/drawable/ic_close.xml new file mode 100644 index 0000000..f820cb4 --- /dev/null +++ b/app/src/main/res/drawable/ic_close.xml @@ -0,0 +1,18 @@ + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4fc2444..7760853 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,13 +6,138 @@ android:layout_height="match_parent" tools:context=".MainActivity"> - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_second_screen.xml b/app/src/main/res/layout/activity_second_screen.xml new file mode 100644 index 0000000..f8bee2f --- /dev/null +++ b/app/src/main/res/layout/activity_second_screen.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + \ 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 65004cf..862c85e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,7 @@ - TmsTemp + frthtask + Какой-то текст Какой-то текст Какой-то текст Какой-то текст Какой-то текст Какой-то текст Какой-то текст Какой-то текст + Первый пункт + Второй пункт + Третий пункт \ No newline at end of file