Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

22 android task #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.krottv.tmstemp">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TmsTemp">
<activity
android:name=".SecondScreenActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
88 changes: 88 additions & 0 deletions app/src/main/java/com/github/krottv/tmstemp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/anim/alpha_infinite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<alpha
android:fromAlpha="0.5"
android:toAlpha="1"
android:duration="2500"
android:repeatMode="reverse"
android:repeatCount="infinite" />
</set>
13 changes: 13 additions & 0 deletions app/src/main/res/anim/rotation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:shareInterpolator="false">

<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:interpolator="@android:anim/linear_interpolator"/>
</set>
15 changes: 15 additions & 0 deletions app/src/main/res/anim/scale_infinite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<scale
android:fromXScale="0.75"
android:fromYScale="0.75"
android:pivotY="50%"
android:pivotX="50%"
android:toXScale="1.0"
android:toYScale="1.0"
android:duration="2500"
android:repeatMode="reverse"
android:repeatCount="infinite"
/>
</set>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/ic_close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M14,14L2,2"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M14,2L2,14"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
</vector>
Loading