├── .gitignore
├── LICENSE.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── abualgait
│ │ └── msayed
│ │ └── egdroidathomechallenge
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── abualgait
│ │ │ └── msayed
│ │ │ └── egdroidathomechallenge
│ │ │ ├── AdapterAlarms.kt
│ │ │ ├── AdapterIncome.kt
│ │ │ ├── AdapterNotification.kt
│ │ │ ├── AdapterShoe.kt
│ │ │ ├── AlarmItem.kt
│ │ │ ├── ArcAnimator
│ │ │ ├── ArcAnimator.java
│ │ │ ├── ArcDebugView.java
│ │ │ ├── ArcMetric.java
│ │ │ ├── ArcUtils.java
│ │ │ └── Side.java
│ │ │ ├── BaseActivity.kt
│ │ │ ├── Extentions.kt
│ │ │ ├── Income.kt
│ │ │ ├── IncomeDetailsActivity.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── MyNotification.kt
│ │ │ ├── Shoe.kt
│ │ │ ├── ShoeBoxes.kt
│ │ │ ├── SplashScreenAnimation.kt
│ │ │ ├── SplashScreenView.kt
│ │ │ ├── TransitionAnimationActivity.kt
│ │ │ └── ViewTransformationAnimation.kt
│ └── res
│ │ ├── anim
│ │ ├── fade_in.xml
│ │ ├── fade_out.xml
│ │ ├── item_animation_fall_down.xml
│ │ └── layout_animation_fall_down.xml
│ │ ├── color
│ │ └── color_list_day_selector.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── box_ceil.png
│ │ ├── box_floor.png
│ │ ├── cirle_solid_drawable.xml
│ │ ├── cirle_stroke_drawable.xml
│ │ ├── egdroid_logo.png
│ │ ├── frame_gradiant.xml
│ │ ├── ic_account_balance_wallet_black_24dp.xml
│ │ ├── ic_add_black_24dp.xml
│ │ ├── ic_arrow_back_black_24dp.xml
│ │ ├── ic_arrow_drop_down_black_24dp.xml
│ │ ├── ic_arrow_forward_black_24dp.xml
│ │ ├── ic_behance.xml
│ │ ├── ic_center_focus_strong_black_24dp.xml
│ │ ├── ic_check_black_24dp.xml
│ │ ├── ic_close_black_24dp.xml
│ │ ├── ic_favorite_black_24dp.xml
│ │ ├── ic_favorite_border_black_24dp.xml
│ │ ├── ic_filter_list_black_24dp.xml
│ │ ├── ic_google_play.xml
│ │ ├── ic_home_black_24dp.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_message_black_24dp.xml
│ │ ├── ic_notifications_black_24dp.xml
│ │ ├── ic_person_black_24dp.xml
│ │ ├── ic_screen_share_black_24dp.xml
│ │ ├── ic_shop_black_24dp.xml
│ │ ├── ic_star_black_24dp.xml
│ │ ├── ic_twitter.xml
│ │ ├── ic_youtube.xml
│ │ ├── nike_logo.png
│ │ ├── profile2020.jpg
│ │ ├── rounded.xml
│ │ ├── shoe1.png
│ │ ├── shoe2.png
│ │ ├── shoe3.png
│ │ └── shoe4.png
│ │ ├── layout
│ │ ├── activity_income_details.xml
│ │ ├── activity_main.xml
│ │ ├── activity_shoe_boxes.xml
│ │ ├── activity_splash_screen_animation.xml
│ │ ├── activity_view_transformation_animation.xml
│ │ ├── activity_view_transitions.xml
│ │ ├── item_alarm.xml
│ │ ├── item_income.xml
│ │ ├── item_notification.xml
│ │ └── item_shoe.xml
│ │ ├── menu
│ │ └── income.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── abualgait
│ └── msayed
│ └── egdroidathomechallenge
│ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── shoe boxes animation.gif
├── splah_screen_gif.gif
├── transition_animation_gif.gif
└── view_tansformation_gif.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 EGDroid
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Custom Animation Challenge
2 | This is a part of [EGDroid at-home challenge](https://github.com/eg-droid/egdroid-at-home-challenge) series.
3 |
4 | ## Contributers
5 | - [Muhammad Sayed Abualgait](https://github.com/abualgait) (Follow him on [Twitter](https://twitter.com/abualgaittwitt), [LinkedIn](https://www.linkedin.com/in/abualgait) and [Facebook](https://m.facebook.com/abualgait))
6 |
7 | ## Splash screen animation
8 |
9 |
10 | *Inspiration: [Gif image](https://gifimage.net/android-splash-screen-animation-gif-2/)*
11 |
12 | ## Activity transition animation
13 |
14 |
15 | *Inspiration: [StackOverflow question](https://stackoverflow.com/q/29846458)*
16 |
17 |
18 | ## View transformation animation
19 |
20 |
21 | *Inspiration: [DroidMotion](https://github.com/bitvale/DroidMotion)*
22 |
23 |
24 | ## View property animation
25 |
26 |
27 | *Inspiration: [Dribbble](https://dribbble.com/shots/6673049--10-Shoe-Boxes-Swipe-Transition)*
28 |
29 |
30 | All GIFs are generated with this [online tool](https://animockup.com/)
31 |
32 | ## License
33 | Copyright (c) 2020 EGDroid
34 |
35 | Licensed under the [MIT License](LICENSE.md)
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.3"
8 |
9 | defaultConfig {
10 | applicationId "com.abualgait.msayed.egdroidathomechallenge"
11 | minSdkVersion 19
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | vectorDrawables.useSupportLibrary = true
17 |
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_8
29 | targetCompatibility JavaVersion.VERSION_1_8
30 | }
31 |
32 | kotlinOptions {
33 | jvmTarget = JavaVersion.VERSION_1_8.toString()
34 | }
35 |
36 | }
37 |
38 | dependencies {
39 | implementation fileTree(dir: 'libs', include: ['*.jar'])
40 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
41 | implementation 'androidx.appcompat:appcompat:1.1.0'
42 | implementation 'androidx.core:core-ktx:1.2.0'
43 |
44 | implementation 'com.google.android.material:material:1.2.0-alpha05'
45 | implementation "androidx.recyclerview:recyclerview:1.2.0-alpha02"
46 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
47 | implementation 'de.hdodenhof:circleimageview:3.1.0'
48 |
49 | testImplementation 'junit:junit:4.12'
50 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
51 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
52 | }
53 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/abualgait/msayed/egdroidathomechallenge/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.abualgait.msayed.egdroidathomechallenge", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
20 |
23 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/AdapterAlarms.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.Switch
8 | import android.widget.TextView
9 | import androidx.recyclerview.widget.RecyclerView
10 |
11 | class AdapterAlarms(
12 | val context: Context,
13 | val items: ArrayList,
14 | val callback: (item: AlarmItem, view: View) -> Unit
15 | ) :
16 | RecyclerView.Adapter() {
17 | private lateinit var recyclerView: RecyclerView
18 | override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
19 | super.onAttachedToRecyclerView(recyclerView)
20 | this.recyclerView = recyclerView
21 | }
22 |
23 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
24 | val inflater = LayoutInflater.from(parent.context)
25 | val view = inflater.inflate(R.layout.item_alarm, parent, false)
26 | return MyViewHolder(view, callback)
27 | }
28 |
29 |
30 | override fun getItemCount(): Int {
31 | return items.size
32 | }
33 |
34 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
35 |
36 | (holder as MyViewHolder).bind(items[position])
37 | }
38 |
39 |
40 | class MyViewHolder(
41 | itemView: View,
42 | val callback: (item: AlarmItem, view: View) -> Unit
43 | ) : RecyclerView.ViewHolder(itemView) {
44 |
45 | fun bind(item: AlarmItem) {
46 |
47 |
48 | itemView.apply {
49 |
50 | findViewById(R.id.time).text = (item.formattedTime)
51 | findViewById(R.id.isSetSwitch).isChecked = (item.iSet)
52 |
53 | for (index in 0 until (itemView as ViewGroup).childCount) {
54 | (itemView).getChildAt(index).apply {
55 | if (tag == context.getString(R.string.day_tag)) {
56 |
57 | if (index + 1 in item.indecesDayOfWeek) {
58 | this.isSelected = true
59 | }
60 | setOnClickListener {
61 |
62 | it.isSelected = !it.isSelected
63 | if (it.isSelected)
64 | item.indecesDayOfWeek.add(index + 1)
65 | }
66 | }
67 | }
68 |
69 | }
70 |
71 | }
72 | itemView.setOnClickListener {
73 | callback(item, itemView)
74 |
75 | }
76 | }
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/AdapterIncome.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.view.animation.AccelerateDecelerateInterpolator
9 | import android.widget.ImageView
10 | import android.widget.TextView
11 | import androidx.core.animation.doOnEnd
12 | import androidx.recyclerview.widget.LinearLayoutManager
13 | import androidx.recyclerview.widget.RecyclerView
14 |
15 | class AdapterIncome(
16 | val context: Context,
17 | val items: ArrayList,
18 | val callback: (item: Income, view: View) -> Unit
19 | ) :
20 | RecyclerView.Adapter() {
21 | private lateinit var recyclerView: RecyclerView
22 | override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
23 | super.onAttachedToRecyclerView(recyclerView)
24 | this.recyclerView = recyclerView
25 | }
26 |
27 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
28 | val inflater = LayoutInflater.from(parent.context)
29 | val view = inflater.inflate(R.layout.item_income, parent, false)
30 | return MyViewHolder(view, callback)
31 | }
32 |
33 |
34 | override fun getItemCount(): Int {
35 | return items.size
36 | }
37 |
38 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
39 |
40 | (holder as MyViewHolder).bind(items[position])
41 | }
42 |
43 |
44 | class MyViewHolder(
45 | itemView: View,
46 | val callback: (item: Income, view: View) -> Unit
47 | ) : RecyclerView.ViewHolder(itemView) {
48 |
49 | fun bind(item: Income) {
50 |
51 | itemView.apply {
52 |
53 | findViewById(R.id.income_image).setImageResource(item.image)
54 | findViewById(R.id.income_title).text = (item.title)
55 | findViewById(R.id.amount).text = (item.amount)
56 | findViewById(R.id.date).text = (item.date)
57 | findViewById(R.id.state).text = (item.status)
58 |
59 |
60 | }
61 | itemView.setOnClickListener {
62 | callback(item, itemView)
63 |
64 | }
65 | }
66 | }
67 |
68 | private inline val LinearLayoutManager.visibleItemsRange: IntRange
69 | get() = findFirstVisibleItemPosition()..findLastVisibleItemPosition()
70 |
71 | fun getScaleDownAnimator(
72 | isScaledDown: Boolean,
73 | income: Income
74 | ): ValueAnimator {
75 | val lm = recyclerView.layoutManager as LinearLayoutManager
76 |
77 | val animator = getValueAnimator(
78 | isScaledDown,
79 | duration = 1000L, delay = 0L, interpolator = AccelerateDecelerateInterpolator()
80 | ) { progress ->
81 |
82 | // Get viewHolder for all visible items and animate attributes
83 | for (i in lm.visibleItemsRange) {
84 | val holder = recyclerView.findViewHolderForLayoutPosition(i) as MyViewHolder
85 | setScaleDownProgress(holder, i, progress, income)
86 | }
87 | }
88 |
89 | // For all the non visible items in the layout manager, notify them to adjust the
90 | // view to the new size
91 | animator.doOnEnd {
92 | repeat(lm.itemCount) { if (it !in lm.visibleItemsRange) notifyItemChanged(it) }
93 | }
94 | return animator
95 | }
96 |
97 | private fun setScaleDownProgress(
98 | holder: MyViewHolder,
99 | position: Int,
100 | progress: Float,
101 | income: Income
102 | ) {
103 | holder.itemView.requestLayout()
104 | if (items[position] != income) {
105 | holder.itemView.alpha = progress
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/AdapterNotification.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import androidx.recyclerview.widget.RecyclerView
9 |
10 | class AdapterNotification(
11 | val context: Context,
12 | val items: ArrayList,
13 | val callback: (item: MyNotification, view: View) -> Unit
14 | ) :
15 | RecyclerView.Adapter() {
16 |
17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
18 | val inflater = LayoutInflater.from(parent.context)
19 | val view = inflater.inflate(R.layout.item_notification, parent, false)
20 | return MyViewHolder(view, callback)
21 | }
22 |
23 |
24 | override fun getItemCount(): Int {
25 | return items.size
26 | }
27 |
28 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
29 | (holder as MyViewHolder).bind(items[position])
30 | }
31 |
32 |
33 | class MyViewHolder(
34 | itemView: View,
35 | val callback: (item: MyNotification, view: View) -> Unit
36 | ) : RecyclerView.ViewHolder(itemView) {
37 |
38 | fun bind(item: MyNotification) {
39 | itemView.apply {
40 |
41 | findViewById(R.id.title).text = (item.title)
42 | findViewById(R.id.details).text = (item.details)
43 | findViewById(R.id.price).text = (item.price)
44 |
45 |
46 | }
47 | itemView.setOnClickListener {
48 | callback(item, itemView)
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/AdapterShoe.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.ImageView
8 | import android.widget.TextView
9 | import androidx.recyclerview.widget.RecyclerView
10 |
11 | class AdapterShoe(
12 | val context: Context,
13 | val items: ArrayList
14 |
15 | ) :
16 | RecyclerView.Adapter() {
17 | private lateinit var recyclerView: RecyclerView
18 |
19 | override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
20 | super.onAttachedToRecyclerView(recyclerView)
21 | this.recyclerView = recyclerView
22 | }
23 |
24 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
25 | val inflater = LayoutInflater.from(parent.context)
26 | val view = inflater.inflate(R.layout.item_shoe, parent, false)
27 | return MyViewHolder(view)
28 | }
29 |
30 |
31 | override fun getItemCount(): Int {
32 | return items.size
33 | }
34 |
35 | override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
36 |
37 | (holder as MyViewHolder).bind(
38 | items[position],
39 | position
40 | )
41 | }
42 |
43 | class MyViewHolder(
44 | itemView: View
45 |
46 | ) : RecyclerView.ViewHolder(itemView) {
47 |
48 | fun bind(
49 | item: Shoe,
50 | position: Int
51 | ) {
52 |
53 | itemView.apply {
54 |
55 |
56 | val box_ceil = findViewById(R.id.box_ceil)
57 | val cover = findViewById(R.id.cover)
58 | val cover_open = findViewById(R.id.cover_open)
59 |
60 | val type = findViewById(R.id.type)
61 | val model = findViewById(R.id.model)
62 | val details = findViewById(R.id.details)
63 | val price = findViewById(R.id.price)
64 |
65 |
66 | if (!item.isOpen && item.progress > 0) {
67 | animateCloseBox(box_ceil!!, cover!!, item.progress, cover_open)
68 | } else {
69 | if (item.isCurrent) {
70 | box_ceil.show()
71 | cover.hide()
72 | cover_open.hide()
73 | } else {
74 | with(item.progress * 100) {
75 | type.translationX = this
76 | model.translationX = this
77 | details.translationX = this
78 | price.translationX = this
79 |
80 | }
81 |
82 | type.animate().translationX(-item.progress).alpha(item.progress)
83 | .startDelay =
84 | 100
85 | model.animate().translationX(-item.progress).alpha(item.progress)
86 | .startDelay =
87 | 200
88 | details.animate().translationX(-item.progress).alpha(item.progress)
89 | .startDelay =
90 | 200
91 | price.animate().translationX(-item.progress).alpha(item.progress)
92 | .startDelay =
93 | 350
94 |
95 | animateOpenBox(
96 | box_ceil!!,
97 | cover!!,
98 | item.progress,
99 | cover_open
100 | )
101 | }
102 | }
103 |
104 | findViewById(R.id.product_image).apply {
105 | setImageResource(item.image)
106 | }
107 |
108 | type.text = (item.type)
109 | model.text = (item.model)
110 | details.text = (item.details)
111 | price.text = (item.price)
112 |
113 | }
114 | }
115 |
116 | private fun animateOpenBox(
117 | box_ceil: ImageView?,
118 | cover: View?,
119 | progress: Float,
120 | coverOpen: View
121 | ) {
122 | box_ceil?.visibility = View.INVISIBLE
123 | cover?.visibility = View.INVISIBLE
124 | coverOpen.show()
125 |
126 | box_ceil?.pivotY =
127 | box_ceil?.height!!.toFloat()
128 | coverOpen.pivotY =
129 | 0f
130 |
131 | if (progress <= 0.5) {
132 | coverOpen.rotationX = progress * 180
133 | box_ceil.rotationX = -progress * 180
134 | } else {
135 | coverOpen.alpha = 0f
136 | box_ceil.show()
137 | box_ceil.rotationX = (progress - 1) * 180
138 | }
139 |
140 | }
141 |
142 | private fun animateCloseBox(
143 | box_ceil: ImageView?,
144 | cover: View?,
145 | progress: Float,
146 | coverOpen: View
147 | ) {
148 |
149 | coverOpen.visibility = View.INVISIBLE
150 | box_ceil?.show()
151 |
152 | box_ceil?.pivotY =
153 | box_ceil?.height!!.toFloat()
154 | cover?.pivotY =
155 | cover?.height!!.toFloat()
156 |
157 | if (progress <= 0.5) {
158 | box_ceil.rotationX = progress * -180
159 | } else {
160 | box_ceil.alpha = 0f
161 | cover.show()
162 | cover.rotationX = progress * -180
163 | }
164 |
165 |
166 | }
167 |
168 | }
169 |
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/AlarmItem.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import java.io.Serializable
4 | import java.sql.Timestamp
5 |
6 | data class AlarmItem(
7 | var time: String
8 | , var iSet: Boolean = false
9 | , var indecesDayOfWeek: MutableSet
10 | ) : Serializable {
11 |
12 | val formattedTime: String
13 | get() = if (time.isNotEmpty()) time else timeNow
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ArcAnimator/ArcAnimator.java:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge.ArcAnimator;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 |
6 | @SuppressWarnings({"unused", "WeakerAccess"})
7 | public class ArcAnimator extends ValueAnimator {
8 |
9 | ArcMetric mArcMetric;
10 | private View mTarget;
11 | // private ValueAnimator mAnimator;
12 | private float mValue;
13 |
14 | private ArcAnimator(ArcMetric arcmetric, View target) {
15 | mArcMetric = arcmetric;
16 | mTarget = (target);
17 |
18 | ofFloat(arcmetric.getStartDegree(), arcmetric.getEndDegree());
19 | addUpdateListener(new AnimatorUpdateListener() {
20 | @Override
21 | public void onAnimationUpdate(ValueAnimator animation) {
22 | setDegree((Float) animation.getAnimatedValue());
23 | }
24 | });
25 | }
26 |
27 | public static ArcAnimator createArcAnimator(View clipView, View nestView,
28 | float degree, Side side) {
29 |
30 | return createArcAnimator(clipView, ArcUtils.centerX(nestView),
31 | ArcUtils.centerY(nestView),
32 | degree, side);
33 | }
34 |
35 | public static ArcAnimator createArcAnimator(View clipView, float endX,
36 | float endY,
37 | float degree, Side side) {
38 |
39 | ArcMetric arcMetric = ArcMetric.evaluate(ArcUtils.centerX(clipView),
40 | ArcUtils.centerY(clipView),
41 | endX, endY, degree, side);
42 | return new ArcAnimator(arcMetric, clipView);
43 | }
44 |
45 | public static ValueAnimator createArcAnimator(View clipView, float startX
46 | , float startY, float endX, float endY,
47 | float degree, Side side) {
48 |
49 | ArcMetric arcMetric = ArcMetric.evaluate(startX, startY, endX, endY,
50 | degree, side);
51 | return getAnimator(arcMetric, clipView);
52 | }
53 |
54 | private static ValueAnimator getAnimator(final ArcMetric arcMetric,
55 | final View target) {
56 | ValueAnimator valueAnimator =
57 | ValueAnimator.ofFloat(arcMetric.getStartDegree(),
58 | arcMetric.getEndDegree());
59 | valueAnimator.addUpdateListener(animation -> {
60 | float degree = (Float) animation.getAnimatedValue();
61 | // mValue = degree;
62 | float x =
63 | arcMetric.getAxisPoint().x + arcMetric.mRadius * ArcUtils.cos(degree);
64 | float y =
65 | arcMetric.getAxisPoint().y - arcMetric.mRadius * ArcUtils.sin(degree);
66 | target.setX(x - target.getWidth() / 2);
67 | target.setY(y - target.getHeight() / 2);
68 | });
69 | return valueAnimator;
70 | }
71 |
72 | float getDegree() {
73 | return mValue;
74 | }
75 |
76 | private void setDegree(float degree) {
77 | mValue = degree;
78 | View clipView = mTarget;
79 | float x =
80 | mArcMetric.getAxisPoint().x + mArcMetric.mRadius * ArcUtils.cos(degree);
81 | float y =
82 | mArcMetric.getAxisPoint().y - mArcMetric.mRadius * ArcUtils.sin(degree);
83 | clipView.setX(x - clipView.getWidth() / 2);
84 | clipView.setY(y - clipView.getHeight() / 2);
85 | }
86 |
87 | @Override
88 | public String toString() {
89 | return mArcMetric.toString();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ArcAnimator/ArcDebugView.java:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge.ArcAnimator;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.util.AttributeSet;
7 | import android.util.DisplayMetrics;
8 | import android.view.View;
9 |
10 | public class ArcDebugView extends View {
11 |
12 | private static final int BLUE = 0xFF2196F3;
13 | private static final int PURPLE = 0xFF9C27B0;
14 | private static final int LIGHTGREEN = 0xFF64DD17;
15 | private static final int STARTPOINT = 0xFFF44336;// red
16 | private static final int ENDPOINT = 0xFFFF9800;//orange
17 | private static final int MIDPOINT = 0xFF795548;//brown
18 | private static final int AXISPOINT = 0xFF4CAF50;//green
19 | private static final int AXISPOINT1 = 0xFF9C27B0;//purple
20 | private static final int ABSOLUTEPOINT = 0xFF424242;//grey
21 | private ArcMetric mArcMetric;
22 | private Paint mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
23 | private Paint mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
24 |
25 | public ArcDebugView(Context context) {
26 | this(context, null);
27 | }
28 |
29 | public ArcDebugView(Context context, AttributeSet attrs) {
30 | this(context, attrs, 0);
31 | }
32 |
33 | public ArcDebugView(Context context, AttributeSet attrs, int defStyleAttr) {
34 | super(context, attrs, defStyleAttr);
35 | mPaintStroke.setStyle(Paint.Style.STROKE);
36 | mPaintStroke.setStrokeWidth(dpToPx(1));
37 | }
38 |
39 | public void drawArcAnimator(ArcAnimator arcAnimator) {
40 | mArcMetric = arcAnimator.mArcMetric;
41 | invalidate();
42 | }
43 |
44 | @Override
45 | protected void onDraw(Canvas canvas) {
46 | super.onDraw(canvas);
47 | if (mArcMetric != null) {
48 | drawElements(canvas);
49 | }
50 | }
51 |
52 | private void drawElements(Canvas canvas) {
53 | drawLines(canvas);
54 | drawCircles(canvas);
55 | drawPoints(canvas);
56 | }
57 |
58 | private void drawPoints(Canvas canvas) {
59 | mPaintFill.setColor(STARTPOINT);
60 | canvas.drawCircle(mArcMetric.mStartPoint.x, mArcMetric.mStartPoint.y,
61 | dpToPx(2), mPaintFill);
62 | mPaintFill.setColor(ENDPOINT);
63 | canvas.drawCircle(mArcMetric.mEndPoint.x, mArcMetric.mEndPoint.y,
64 | dpToPx(2), mPaintFill);
65 | mPaintFill.setColor(MIDPOINT);
66 | canvas.drawCircle(mArcMetric.mMidPoint.x, mArcMetric.mMidPoint.y,
67 | dpToPx(2), mPaintFill);
68 | mPaintFill.setColor(AXISPOINT);
69 | canvas.drawCircle(mArcMetric.mAxisPoint[Side.RIGHT.value].x,
70 | mArcMetric.mAxisPoint[Side.RIGHT.value].y, dpToPx(3),
71 | mPaintFill);
72 | mPaintFill.setColor(AXISPOINT1);
73 | canvas.drawCircle(mArcMetric.mAxisPoint[Side.LEFT.value].x,
74 | mArcMetric.mAxisPoint[Side.LEFT.value].y, dpToPx(3),
75 | mPaintFill);
76 | mPaintFill.setColor(ABSOLUTEPOINT);
77 | canvas.drawCircle(mArcMetric.mZeroPoint.x, mArcMetric.mZeroPoint.y,
78 | dpToPx(2), mPaintFill);
79 | }
80 |
81 | private void drawLines(Canvas canvas) {
82 | mPaintStroke.setColor(PURPLE);
83 | canvas.drawLine(mArcMetric.mStartPoint.x, mArcMetric.mStartPoint.y,
84 | mArcMetric.mEndPoint.x, mArcMetric.mEndPoint.y, mPaintStroke);
85 | canvas.drawLine(mArcMetric.mStartPoint.x, mArcMetric.mStartPoint.y,
86 | mArcMetric.mAxisPoint[mArcMetric.mSide.value].x,
87 | mArcMetric.mAxisPoint[mArcMetric.mSide.value].y, mPaintStroke);
88 | canvas.drawLine(mArcMetric.mEndPoint.x, mArcMetric.mEndPoint.y,
89 | mArcMetric.mAxisPoint[mArcMetric.mSide.value].x,
90 | mArcMetric.mAxisPoint[mArcMetric.mSide.value].y, mPaintStroke);
91 | }
92 |
93 | private void drawCircles(Canvas canvas) {
94 | mPaintStroke.setColor(BLUE);
95 | canvas.drawCircle(mArcMetric.mStartPoint.x, mArcMetric.mStartPoint.y,
96 | mArcMetric.mRadius, mPaintStroke);
97 | canvas.drawCircle(mArcMetric.mEndPoint.x, mArcMetric.mEndPoint.y,
98 | mArcMetric.mRadius, mPaintStroke);
99 | mPaintStroke.setColor(LIGHTGREEN);
100 | canvas.drawCircle(mArcMetric.mAxisPoint[mArcMetric.mSide.value].x,
101 | mArcMetric.mAxisPoint[mArcMetric.mSide.value].y,
102 | mArcMetric.mRadius, mPaintStroke);
103 | }
104 |
105 | public int dpToPx(int dp) {
106 | DisplayMetrics displayMetrics =
107 | getContext().getResources().getDisplayMetrics();
108 | return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
109 | }
110 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ArcAnimator/ArcMetric.java:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge.ArcAnimator;
2 |
3 | import android.graphics.PointF;
4 |
5 | import androidx.annotation.NonNull;
6 |
7 | import java.util.Arrays;
8 |
9 | @SuppressWarnings("WeakerAccess")
10 | public class ArcMetric {
11 |
12 | public float mRadius;
13 | PointF mStartPoint = new PointF();
14 | PointF mEndPoint = new PointF();
15 | PointF mMidPoint = new PointF();
16 | PointF[] mAxisPoint = new PointF[2];
17 |
18 | //SEGMENTS. This Segments create virtual triangle except mZeroStartSegment
19 | PointF mZeroPoint = new PointF();
20 | float mStartEndSegment;
21 | float mMidAxisSegment;
22 | float mZeroStartSegment;
23 |
24 | //DEGREES.
25 |
26 | float mAnimationDegree;
27 | float mSideDegree;
28 | float mZeroStartDegree;
29 | float mStartDegree;
30 | float mEndDegree;
31 |
32 | //Side of animation
33 | Side mSide;
34 |
35 | /**
36 | * Create new {@link ArcMetric} instance and do all calculations below
37 | * and finally return ready to use object
38 | */
39 | public static ArcMetric evaluate(float startX, float startY,
40 | float endX, float endY,
41 | float degree, Side side) {
42 | ArcMetric arcMetric = new ArcMetric();
43 | arcMetric.mStartPoint.set(startX, startY);
44 | arcMetric.mEndPoint.set(endX, endY);
45 | arcMetric.setDegree(degree);
46 | arcMetric.mSide = side;
47 | arcMetric.createAxisVariables();
48 |
49 | arcMetric.calcStartEndSeg();
50 | arcMetric.calcRadius();
51 | arcMetric.calcMidAxisSeg();
52 | arcMetric.calcMidPoint();
53 | arcMetric.calcAxisPoints();
54 | arcMetric.calcZeroPoint();
55 | arcMetric.calcDegrees();
56 |
57 | return arcMetric;
58 | }
59 |
60 | private void createAxisVariables() {
61 | for (int i = 0; i < mAxisPoint.length; i++)
62 | mAxisPoint[i] = new PointF();
63 | }
64 |
65 | private void calcStartEndSeg() {
66 | mStartEndSegment =
67 | (float) Math.sqrt(Math.pow(mStartPoint.x - mEndPoint.x, 2) +
68 | Math.pow(mStartPoint.y - mEndPoint.y, 2));
69 | }
70 |
71 | private void calcRadius() {
72 | mSideDegree = (180 - mAnimationDegree) / 2;
73 | mRadius =
74 | mStartEndSegment / ArcUtils.sin(mAnimationDegree) * ArcUtils.sin(mSideDegree);
75 | }
76 |
77 | private void calcMidAxisSeg() {
78 | mMidAxisSegment = mRadius * ArcUtils.sin(mSideDegree);
79 | }
80 |
81 | private void calcMidPoint() {
82 | mMidPoint.x =
83 | mStartPoint.x + mStartEndSegment / 2 * (mEndPoint.x - mStartPoint.x) / mStartEndSegment;
84 | mMidPoint.y =
85 | mStartPoint.y + mStartEndSegment / 2 * (mEndPoint.y - mStartPoint.y) / mStartEndSegment;
86 | }
87 |
88 | private void calcAxisPoints() {
89 | if (mStartPoint.y > mEndPoint.y || mStartPoint.y == mEndPoint.y) {
90 | mAxisPoint[0].x =
91 | mMidPoint.x + mMidAxisSegment * (mEndPoint.y - mStartPoint.y) / mStartEndSegment;
92 | mAxisPoint[0].y =
93 | mMidPoint.y - mMidAxisSegment * (mEndPoint.x - mStartPoint.x) / mStartEndSegment;
94 |
95 | mAxisPoint[1].x =
96 | mMidPoint.x - mMidAxisSegment * (mEndPoint.y - mStartPoint.y) / mStartEndSegment;
97 | mAxisPoint[1].y =
98 | mMidPoint.y + mMidAxisSegment * (mEndPoint.x - mStartPoint.x) / mStartEndSegment;
99 | } else {
100 | mAxisPoint[0].x =
101 | mMidPoint.x - mMidAxisSegment * (mEndPoint.y - mStartPoint.y) / mStartEndSegment;
102 | mAxisPoint[0].y =
103 | mMidPoint.y + mMidAxisSegment * (mEndPoint.x - mStartPoint.x) / mStartEndSegment;
104 |
105 | mAxisPoint[1].x =
106 | mMidPoint.x + mMidAxisSegment * (mEndPoint.y - mStartPoint.y) / mStartEndSegment;
107 | mAxisPoint[1].y =
108 | mMidPoint.y - mMidAxisSegment * (mEndPoint.x - mStartPoint.x) / mStartEndSegment;
109 | }
110 | }
111 |
112 | private void calcZeroPoint() {
113 | switch (mSide) {
114 | case RIGHT:
115 | mZeroPoint.x = mAxisPoint[Side.RIGHT.value].x + mRadius;
116 | mZeroPoint.y = mAxisPoint[Side.RIGHT.value].y;
117 | break;
118 | case LEFT:
119 | mZeroPoint.x = mAxisPoint[Side.LEFT.value].x - mRadius;
120 | mZeroPoint.y = mAxisPoint[Side.LEFT.value].y;
121 | break;
122 | }
123 | }
124 |
125 | private void calcDegrees() {
126 | mZeroStartSegment =
127 | (float) Math.sqrt(Math.pow(mZeroPoint.x - mStartPoint.x, 2) +
128 | Math.pow(mZeroPoint.y - mStartPoint.y, 2));
129 | mZeroStartDegree =
130 | ArcUtils.acos((2 * Math.pow(mRadius, 2) - Math.pow(mZeroStartSegment, 2)) / (2 * Math.pow(mRadius, 2)));
131 | switch (mSide) {
132 | case RIGHT:
133 | if (mStartPoint.y <= mZeroPoint.y) {
134 | if (mStartPoint.y > mEndPoint.y ||
135 | (mStartPoint.y == mEndPoint.y && mStartPoint.x > mEndPoint.x)) {
136 | mStartDegree = mZeroStartDegree;
137 | mEndDegree = mStartDegree + mAnimationDegree;
138 | } else {
139 | mStartDegree = mZeroStartDegree;
140 | mEndDegree = mStartDegree - mAnimationDegree;
141 | }
142 | } else if (mStartPoint.y >= mZeroPoint.y) {
143 | if (mStartPoint.y < mEndPoint.y ||
144 | (mStartPoint.y == mEndPoint.y && mStartPoint.x > mEndPoint.x)) {
145 | mStartDegree = 0 - mZeroStartDegree;
146 | mEndDegree = mStartDegree - mAnimationDegree;
147 | } else {
148 | mStartDegree = 0 - mZeroStartDegree;
149 | mEndDegree = mStartDegree + mAnimationDegree;
150 | }
151 | }
152 | break;
153 | case LEFT:
154 | if (mStartPoint.y <= mZeroPoint.y) {
155 | if (mStartPoint.y > mEndPoint.y ||
156 | (mStartPoint.y == mEndPoint.y && mStartPoint.x < mEndPoint.x)) {
157 | mStartDegree = 180 - mZeroStartDegree;
158 | mEndDegree = mStartDegree - mAnimationDegree;
159 | } else {
160 | mStartDegree = 180 - mZeroStartDegree;
161 | mEndDegree = mStartDegree + mAnimationDegree;
162 | }
163 | } else if (mStartPoint.y >= mZeroPoint.y) {
164 | if (mStartPoint.y < mEndPoint.y ||
165 | (mStartPoint.y == mEndPoint.y && mStartPoint.x < mEndPoint.x)) {
166 | mStartDegree = 180 + mZeroStartDegree;
167 | mEndDegree = mStartDegree + mAnimationDegree;
168 | } else {
169 | mStartDegree = 180 + mZeroStartDegree;
170 | mEndDegree = mStartDegree - mAnimationDegree;
171 | }
172 | }
173 | break;
174 | }
175 | }
176 |
177 | public void setDegree(float degree) {
178 | degree = Math.abs(degree);
179 | if (degree > 180)
180 | setDegree(degree % 180);
181 | else if (degree == 180)
182 | setDegree(degree - 1);
183 | else if (degree < 30)
184 | setDegree(30);
185 | else
186 | this.mAnimationDegree = degree;
187 | }
188 |
189 | public PointF getAxisPoint() {
190 | return mAxisPoint[mSide.value];
191 | }
192 |
193 | /**
194 | * Return evaluated start degree
195 | *
196 | * @return the start degree
197 | */
198 | public float getStartDegree() {
199 | return mStartDegree;
200 | }
201 |
202 | /**
203 | * Return evaluated end degree
204 | *
205 | * @return the end degree
206 | */
207 | public float getEndDegree() {
208 | return mEndDegree;
209 | }
210 |
211 | public float getDegree(float percentage) {
212 | return mStartDegree + (mEndDegree - mStartDegree) * percentage;
213 | }
214 |
215 | @NonNull
216 | @Override
217 | public String toString() {
218 | return "ArcMetric{" +
219 | "\nmStartPoint=" + mStartPoint +
220 | "\n mEndPoint=" + mEndPoint +
221 | "\n mMidPoint=" + mMidPoint +
222 | "\n mAxisPoint=" + Arrays.toString(mAxisPoint) +
223 | "\n mZeroPoint=" + mZeroPoint +
224 | "\n mStartEndSegment=" + mStartEndSegment +
225 | "\n mRadius=" + mRadius +
226 | "\n mMidAxisSegment=" + mMidAxisSegment +
227 | "\n mZeroStartSegment=" + mZeroStartSegment +
228 | "\n mAnimationDegree=" + mAnimationDegree +
229 | "\n mSideDegree=" + mSideDegree +
230 | "\n mZeroStartDegree=" + mZeroStartDegree +
231 | "\n mStartDegree=" + mStartDegree +
232 | "\n mEndDegree=" + mEndDegree +
233 | "\n mSide=" + mSide +
234 | '}';
235 | }
236 | }
237 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ArcAnimator/ArcUtils.java:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge.ArcAnimator;
2 |
3 | import android.view.View;
4 |
5 | public class ArcUtils {
6 |
7 | public static float sin(double degree) {
8 | return (float) Math.sin(Math.toRadians(degree));
9 | }
10 |
11 | public static float cos(double degree) {
12 | return (float) Math.cos(Math.toRadians(degree));
13 | }
14 |
15 | public static float asin(double value) {
16 | return (float) Math.toDegrees(Math.asin(value));
17 | }
18 |
19 | static float acos(double value) {
20 | return (float) Math.toDegrees(Math.acos(value));
21 | }
22 |
23 | static float centerX(View view) {
24 | return view.getX() + view.getWidth() / 2f;
25 | }
26 |
27 | static float centerY(View view) {
28 | return view.getY() + view.getHeight() / 2f;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ArcAnimator/Side.java:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge.ArcAnimator;
2 |
3 | public enum Side {
4 | RIGHT(0), LEFT(1);
5 |
6 | final int value;
7 |
8 | Side(int value) {
9 | this.value = value;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Bundle
5 | import androidx.appcompat.app.AppCompatActivity
6 |
7 | @SuppressLint("Registered")
8 | open class BaseActivity : AppCompatActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
12 | }
13 |
14 | override fun onPause() {
15 | super.onPause()
16 | overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
17 | }
18 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/Extentions.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.animation.TimeInterpolator
4 | import android.animation.ValueAnimator
5 | import android.content.Context
6 | import android.content.res.Resources
7 | import android.graphics.Point
8 | import android.util.Log
9 | import android.view.View
10 | import android.view.WindowManager
11 | import androidx.core.view.ViewCompat
12 | import androidx.viewpager2.widget.ViewPager2
13 | import java.text.SimpleDateFormat
14 | import java.util.*
15 |
16 | val Int.dp: Int
17 | get() = (this / Resources.getSystem().displayMetrics.density).toInt()
18 | val Int.px: Int
19 | get() = (this * Resources.getSystem().displayMetrics.density).toInt()
20 |
21 | fun View.hide() {
22 | visibility = View.GONE
23 | }
24 |
25 | fun View.invisible() {
26 | visibility = View.INVISIBLE
27 | }
28 |
29 | fun View.show() {
30 | visibility = View.VISIBLE
31 | }
32 |
33 |
34 | inline val Context.screenWidth: Int
35 | get() = Point().also {
36 | (getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(
37 | it
38 | )
39 | }.x
40 | inline val View.screenWidth: Int
41 | get() = context!!.screenWidth
42 |
43 | fun getValueAnimator(
44 | forward: Boolean = true,
45 | duration: Long,
46 | delay: Long,
47 | interpolator: TimeInterpolator,
48 | updateListener: (progress: Float) -> Unit
49 | ): ValueAnimator {
50 | val a =
51 | if (forward) ValueAnimator.ofFloat(0f, 1f)
52 | else ValueAnimator.ofFloat(1f, 0f)
53 | a.addUpdateListener { updateListener(it.animatedValue as Float) }
54 | a.duration = duration
55 | a.startDelay = delay
56 | a.interpolator = interpolator
57 | a.repeatMode = ValueAnimator.REVERSE
58 | a.repeatCount = 0
59 | return a
60 | }
61 |
62 | val timeNow = SimpleDateFormat("hh:mm a", Locale.US).format(Date())
63 |
64 | fun ViewPager2.setShowSideItems(pageMarginPx: Int, offsetPx: Int) {
65 |
66 | clipToPadding = false
67 | clipChildren = false
68 | offscreenPageLimit = 3
69 |
70 | setPageTransformer { page, position ->
71 |
72 | val offset = position * -(2 * offsetPx + pageMarginPx)
73 | if (this.orientation == ViewPager2.ORIENTATION_HORIZONTAL) {
74 | if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
75 | page.translationX = -offset
76 | } else {
77 | page.translationX = offset
78 | }
79 | } else {
80 | page.translationY = offset
81 | }
82 | }
83 |
84 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/Income.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import androidx.annotation.DrawableRes
4 | import java.io.Serializable
5 |
6 | data class Income(
7 | @DrawableRes var image: Int
8 | , var title: String
9 | , var amount: String
10 | , var date: String
11 | , var status: String
12 | , @DrawableRes var icon: Int
13 | ) : Serializable
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/IncomeDetailsActivity.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.animation.AnimatorSet
4 | import android.os.Bundle
5 | import android.view.View
6 | import android.view.ViewTreeObserver.OnGlobalLayoutListener
7 | import android.view.animation.AccelerateInterpolator
8 | import android.view.animation.AnimationUtils
9 | import android.view.animation.AnticipateOvershootInterpolator
10 | import androidx.appcompat.app.AppCompatActivity
11 | import androidx.core.animation.doOnEnd
12 | import androidx.core.animation.doOnStart
13 | import androidx.recyclerview.widget.LinearLayoutManager
14 | import kotlinx.android.synthetic.main.activity_income_details.*
15 | import kotlinx.android.synthetic.main.item_income.*
16 |
17 |
18 | class IncomeDetailsActivity : AppCompatActivity() {
19 | var income = Income(0, "", "", "", "", 0)
20 |
21 | var items = arrayListOf().apply {
22 | add(
23 | MyNotification(
24 | "In App Purchase",
25 | "including VAT 10%",
26 | "$14,340"
27 | )
28 | )
29 |
30 | add(
31 | MyNotification(
32 | "Interstitial Ads",
33 | "including VAT 15%",
34 | "$12,000"
35 | )
36 | )
37 | add(
38 | MyNotification(
39 | "In App Purchase",
40 | "including VAT 20%",
41 | "$10,000"
42 | )
43 | )
44 | add(
45 | MyNotification(
46 | "In App Purchase",
47 | "including VAT 10%",
48 | "$2,400"
49 | )
50 | )
51 |
52 | add(
53 | MyNotification(
54 | "In App Purchase",
55 | "including VAT 10%",
56 | "$14,340"
57 | )
58 | )
59 |
60 | add(
61 | MyNotification(
62 | "In App Purchase",
63 | "including VAT 15%",
64 | "$12,000"
65 | )
66 | )
67 | add(
68 | MyNotification(
69 | "In App Purchase",
70 | "including VAT 20%",
71 | "$10,000"
72 | )
73 | )
74 | add(
75 | MyNotification(
76 | "In App Purchase",
77 | "including VAT 10%",
78 | "$2,400"
79 | )
80 | )
81 |
82 |
83 | }
84 |
85 |
86 | override fun onCreate(savedInstanceState: Bundle?) {
87 | super.onCreate(savedInstanceState)
88 | setContentView(R.layout.activity_income_details)
89 | getIntentData()
90 | animateViews()
91 | container.viewTreeObserver.addOnGlobalLayoutListener(
92 | object : OnGlobalLayoutListener {
93 | override fun onGlobalLayout() { // Layout has happened here.
94 | fab_close.translationY = container.height + fab_close.y
95 | fab_check.translationY = container.height + fab_close.y
96 | constraintLayout.translationY = -(constraintLayout.height).toFloat()
97 | container.viewTreeObserver.removeOnGlobalLayoutListener(this)
98 | }
99 | })
100 | }
101 |
102 | private fun animateViews() {
103 |
104 | val viewHeightAnimator =
105 | getValueAnimator(false, DURATION, DELAY, AccelerateInterpolator()) { progress ->
106 | /* val viewWidth = constraintLayout.width
107 | val viewHeight = (progress * 150.px).toInt()
108 | val ly = ConstraintLayout.LayoutParams(viewWidth, viewHeight)
109 | constraintLayout.layoutParams = ly*/
110 | constraintLayout.translationY = -progress * constraintLayout.height
111 | }
112 | viewHeightAnimator.doOnEnd {
113 | setAdapter()
114 |
115 | }
116 | val toolbarAnimator =
117 | getValueAnimator(true, DURATION, DELAY, AccelerateInterpolator()) { progress ->
118 | toolbar.alpha = progress
119 | }
120 |
121 |
122 | val fabCloseAnimator =
123 | getValueAnimator(
124 | false,
125 | DURATION,
126 | DELAY,
127 | AnticipateOvershootInterpolator()//AccelerateInterpolator()
128 | ) { progress ->
129 | fab_close.translationY = progress * (fab_check.height + toolbar.height).toFloat()
130 | }
131 | fabCloseAnimator.doOnStart {
132 | fab_check.show()
133 | }
134 |
135 | val fabCheckAnimator =
136 | getValueAnimator(
137 | false,
138 | DURATION,
139 | DELAY + 10L,
140 | AnticipateOvershootInterpolator()// AccelerateInterpolator()
141 | ) { progress ->
142 | fab_check.translationY = progress * (fab_check.height + toolbar.height).toFloat()
143 | }
144 | val set = AnimatorSet()
145 | set.play(viewHeightAnimator).before(fabCheckAnimator).with(fabCloseAnimator)
146 | .with(toolbarAnimator)
147 | set.start()
148 |
149 | }
150 |
151 | private fun setAdapter() {
152 | val mAdapter = AdapterNotification(this, items) { income, view ->
153 | }
154 | recyclerNotifications.apply {
155 | adapter = mAdapter
156 | layoutAnimation =
157 | AnimationUtils.loadLayoutAnimation(
158 | this@IncomeDetailsActivity,
159 | R.anim.layout_animation_fall_down
160 | )
161 |
162 | layoutManager = LinearLayoutManager(this@IncomeDetailsActivity)
163 |
164 | }
165 | }
166 |
167 | private fun setIncome() {
168 | income_image.setImageResource(income.image)
169 | income_title.text = income.title
170 | amount.text = income.amount
171 | date.text = income.date
172 | state.text = income.status
173 | }
174 |
175 | private fun getIntentData() {
176 | income = intent.getSerializableExtra("item") as Income
177 | setIncome()
178 |
179 | }
180 |
181 | companion object {
182 | val DURATION = 900L
183 | val DELAY = 200L
184 | }
185 |
186 | fun backClick(view: View) {
187 | finish()
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.view.View
6 | import kotlinx.android.synthetic.main.activity_main.*
7 |
8 | class MainActivity : BaseActivity(), View.OnClickListener {
9 |
10 | override fun onCreate(savedInstanceState: Bundle?) {
11 | super.onCreate(savedInstanceState)
12 | setContentView(R.layout.activity_main)
13 | initViewsListeners()
14 | }
15 |
16 | private fun initViewsListeners() {
17 | splash_screen_animation.setOnClickListener(this)
18 | transition_animation.setOnClickListener(this)
19 | view_transformation_animation.setOnClickListener(this)
20 | view_pager_animations.setOnClickListener(this)
21 | }
22 |
23 | override fun onClick(view: View?) {
24 | when (view?.id) {
25 | R.id.splash_screen_animation -> {
26 | Intent(this, SplashScreenAnimation::class.java).apply {
27 | startActivity(this)
28 | }
29 | }
30 | R.id.transition_animation -> {
31 | Intent(this, TransitionAnimationActivity::class.java).apply {
32 | startActivity(this)
33 | }
34 | }
35 |
36 | R.id.view_transformation_animation -> {
37 | Intent(this, ViewTransformationAnimation::class.java).apply {
38 | startActivity(this)
39 | }
40 |
41 | }
42 |
43 | R.id.view_pager_animations -> {
44 | Intent(this, ShoeBoxes::class.java).apply {
45 | startActivity(this)
46 | }
47 |
48 | }
49 | }
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/MyNotification.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | data class MyNotification(val title: String, val details: String, val price: String)
4 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/Shoe.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import androidx.annotation.DrawableRes
4 |
5 | data class Shoe(
6 | @DrawableRes var image: Int
7 | , var type: String
8 | , var model: String
9 | , var details: String
10 | , var price: String
11 | , var rate: String
12 | , var isOpen: Boolean = false
13 | , var isCurrent: Boolean = false
14 | , var progress: Float = 0f
15 |
16 | )
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ShoeBoxes.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.os.Bundle
4 | import android.util.Log
5 | import androidx.appcompat.app.AppCompatActivity
6 | import androidx.viewpager2.widget.ViewPager2
7 | import kotlinx.android.synthetic.main.activity_shoe_boxes.*
8 |
9 | //TODO need to handle viewpager reverse page changes [LTR]
10 | class ShoeBoxes : AppCompatActivity() {
11 |
12 | var items = arrayListOf().apply {
13 | add(Shoe(R.drawable.shoe1, "Men's Shoe", "Nike Air Max", "Tiger", "$150", "4.3"))
14 | add(Shoe(R.drawable.shoe2, "Men's Shoe", "Nike Air MaxVapore", "270", "$180", "3.3"))
15 | add(
16 | Shoe(
17 | R.drawable.shoe3,
18 | "Men's Shoe",
19 | "Nike React Prestro",
20 | "Rabid Panda",
21 | "$250",
22 | "4.5"
23 | )
24 | )
25 | add(Shoe(R.drawable.shoe2, "Men's Shoe", "Nike Blade", "Flynik2", "$100", "3.9"))
26 | add(Shoe(R.drawable.shoe1, "Men's Shoe", "Nike Blade", "Flynik2", "$100", "3.9"))
27 | }
28 |
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | setContentView(R.layout.activity_shoe_boxes)
32 | setAdapter()
33 | }
34 |
35 | var isSwipeRight = false
36 | private fun setAdapter() {
37 |
38 | val pageMarginPx = resources.getDimensionPixelOffset(R.dimen.pageMargin)
39 | val offsetPx = resources.getDimensionPixelOffset(R.dimen.offset)
40 | val mAdapter = AdapterShoe(this@ShoeBoxes, items)
41 |
42 | recycler_shoes.apply {
43 |
44 | items[0].isOpen = true
45 | items[0].isCurrent = true
46 | mAdapter.notifyItemChanged(0)
47 |
48 | rate.text = items[0].rate
49 |
50 | registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
51 |
52 | override fun onPageScrolled(
53 | position: Int,
54 | positionOffset: Float,
55 | positionOffsetPixels: Int
56 | ) {
57 | super.onPageScrolled(position, positionOffset, positionOffsetPixels)
58 | Log.e("progress ", (1 - positionOffset).toString())
59 | Log.e("position ", position.toString())
60 | Log.e("isSwipeRight ", isSwipeRight.toString())
61 | if (positionOffset > 0) {
62 | //animate rate
63 | rate.text = items[position].rate
64 | rate.translationX = rate_frame.width / 2f
65 | rate.alpha = 0f
66 | rate.animate().translationX(-positionOffset)
67 | .alpha(positionOffset)
68 | .start()
69 |
70 | //close current page
71 | items[position].isOpen = false
72 | items[position].progress = positionOffset
73 | mAdapter.notifyItemChanged(position)
74 | //open next page
75 | items[position + 1].isOpen = true
76 | items[position + 1].progress = positionOffset
77 | mAdapter.notifyItemChanged(position + 1)
78 |
79 | }
80 | }
81 |
82 | })
83 | setShowSideItems(pageMarginPx, offsetPx)
84 | adapter = mAdapter
85 |
86 |
87 | }
88 |
89 |
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/SplashScreenAnimation.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.os.Bundle
4 |
5 | class SplashScreenAnimation : BaseActivity() {
6 |
7 | override fun onCreate(savedInstanceState: Bundle?) {
8 | super.onCreate(savedInstanceState)
9 | setContentView(SplashScreenView(context = this))
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/SplashScreenView.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.animation.Animator
4 | import android.animation.AnimatorSet
5 | import android.content.Context
6 | import android.graphics.Canvas
7 | import android.graphics.drawable.GradientDrawable
8 | import android.util.AttributeSet
9 | import android.view.Gravity
10 | import android.view.ViewGroup
11 | import android.view.animation.AccelerateInterpolator
12 | import android.widget.ImageView
13 | import android.widget.LinearLayout
14 | import android.widget.TextView
15 | import androidx.annotation.ColorInt
16 | import androidx.core.animation.doOnEnd
17 |
18 |
19 | class SplashScreenView @JvmOverloads constructor(
20 | context: Context,
21 | attrs: AttributeSet? = null,
22 | defStyleAttr: Int = 0
23 | ) : LinearLayout(context, attrs, defStyleAttr) {
24 | val set = AnimatorSet()
25 | @ColorInt
26 | val textColor = resources.getColor(R.color.colorSilver)
27 |
28 | private lateinit var imgs: Array
29 | private lateinit var textView: TextView
30 | private var circle = GradientDrawable()
31 |
32 | val layoutParamsContainer =
33 | LayoutParams(100.px, ViewGroup.LayoutParams.WRAP_CONTENT)
34 |
35 | init {
36 |
37 | orientation = VERTICAL
38 | gravity = Gravity.CENTER
39 | background = resources.getDrawable(R.color.colorBackground)
40 | val layoutParams = LayoutParams(
41 | ViewGroup.LayoutParams.MATCH_PARENT,
42 | ViewGroup.LayoutParams.MATCH_PARENT
43 | )
44 | setLayoutParams(layoutParams)
45 | drawCircularBulbs(20.px)
46 | drawFadingText()
47 | }
48 |
49 |
50 | private fun animateView() {
51 |
52 |
53 | for ((index, it) in imgs.withIndex()) {
54 | if (index == imgs.size - 1) {
55 | set.addListener(object : Animator.AnimatorListener {
56 | override fun onAnimationRepeat(p0: Animator?) {
57 | }
58 |
59 | override fun onAnimationEnd(p0: Animator?) {
60 | removeSetListeners()
61 | animateView()
62 | fadTextView()
63 | }
64 |
65 | override fun onAnimationCancel(p0: Animator?) {
66 | }
67 |
68 | override fun onAnimationStart(p0: Animator?) {
69 | }
70 |
71 | })
72 |
73 | }
74 | val scaleDown =
75 | getValueAnimator(
76 | false, DURATION, DURATION * index, AccelerateInterpolator()
77 | ) { progress ->
78 | it?.scaleX = progress
79 | it?.scaleY = progress
80 |
81 | }
82 |
83 | val scaleUp =
84 | getValueAnimator(
85 | true,
86 | DURATION,
87 | DURATION * index,
88 | AccelerateInterpolator()
89 | ) { progress ->
90 |
91 | it?.scaleX = progress
92 | it?.scaleY = progress
93 | }
94 |
95 |
96 | set.play(scaleDown).before(scaleUp)
97 | set.start()
98 |
99 | }
100 |
101 |
102 | }
103 |
104 | private fun fadTextView() {
105 | val alpha =
106 | getValueAnimator(
107 | false, DURATION * 4, DURATION, AccelerateInterpolator()
108 | ) { progress ->
109 | textView.alpha = progress
110 | }
111 |
112 | alpha.doOnEnd {
113 | textView.alpha = 1f
114 | }
115 | alpha.start()
116 | }
117 |
118 | override fun onDraw(canvas: Canvas?) {
119 | super.onDraw(canvas)
120 | imgs.reverse()
121 | animateView()
122 | }
123 |
124 | private fun drawCircularBulbs(size: Int) {
125 | removeAllViews()
126 | imgs = arrayOfNulls(OBJECT_SIZE)
127 |
128 | circle.shape = GradientDrawable.OVAL
129 | circle.setColor(textColor)
130 |
131 | layoutParamsContainer.gravity = Gravity.CENTER
132 | layoutParamsContainer.setMargins(MARGIN, MARGIN, MARGIN, MARGIN)
133 |
134 | val rel = arrayOfNulls(OBJECT_SIZE)
135 | for (i in 0 until OBJECT_SIZE) {
136 | rel[i] = LinearLayout(context)
137 | rel[i]!!.gravity = if (i % 2 == 0) Gravity.START else Gravity.END
138 | rel[i]!!.layoutParams = layoutParamsContainer
139 | imgs[i] = ImageView(context)
140 |
141 | imgs[i]?.setBackgroundDrawable(circle)
142 | imgs[i]?.layoutParams = LayoutParams(size * (i + 1), size * (i + 1))
143 | rel[i]!!.addView(imgs[i])
144 | addView(rel[i])
145 | }
146 |
147 | }
148 |
149 | private fun drawFadingText() {
150 | textView = TextView(context)
151 | textView.text = context.getString(R.string.egdroid_challenge_str).toUpperCase()
152 | textView.setTextColor(textColor)
153 | textView.textSize = 8.px.toFloat()
154 | val ly = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
155 | textView.layoutParams = ly
156 | ly.setMargins(MARGIN, MARGIN, MARGIN, MARGIN)
157 | addView(textView)
158 | }
159 |
160 | override fun onDetachedFromWindow() {
161 | super.onDetachedFromWindow()
162 | removeSetListeners()
163 | }
164 |
165 | private fun removeSetListeners() {
166 | set.removeAllListeners()
167 | set.end()
168 | set.cancel()
169 | }
170 |
171 | companion object {
172 | private var OBJECT_SIZE = 4
173 | private var DURATION = 600L
174 | private var MARGIN = 15.px
175 | }
176 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/TransitionAnimationActivity.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.view.animation.AnimationUtils
6 | import androidx.cardview.widget.CardView
7 | import androidx.core.animation.doOnEnd
8 | import androidx.core.app.ActivityOptionsCompat
9 | import androidx.recyclerview.widget.LinearLayoutManager
10 | import kotlinx.android.synthetic.main.activity_view_transitions.*
11 |
12 | class TransitionAnimationActivity : BaseActivity() {
13 |
14 | var items = arrayListOf().apply {
15 | add(
16 | Income(
17 | R.drawable.egdroid_logo,
18 | "Eg Droid",
19 | "120",
20 | "1/2/2000",
21 | "Recieved",
22 | R.drawable.egdroid_logo
23 | )
24 | )
25 |
26 | add(
27 | Income(
28 | R.drawable.ic_google_play,
29 | "Google Play",
30 | "200",
31 | "20/3/2010",
32 | "Recieved",
33 | R.drawable.ic_google_play
34 | )
35 | )
36 |
37 | add(
38 | Income(
39 | R.drawable.ic_youtube,
40 | "Youtube",
41 | "300",
42 | "22/4/2020",
43 | "Recieved",
44 | R.drawable.ic_youtube
45 | )
46 | )
47 |
48 | add(
49 | Income(
50 | R.drawable.ic_twitter,
51 | "Twitter",
52 | "120",
53 | "20/3/2019",
54 | "Recieved",
55 | R.drawable.ic_twitter
56 | )
57 | )
58 |
59 | add(
60 | Income(
61 | R.drawable.egdroid_logo,
62 | "Eg Droid",
63 | "120",
64 | "20/3/1993",
65 | "Recieved",
66 | R.drawable.egdroid_logo
67 | )
68 | )
69 |
70 |
71 | add(
72 | Income(
73 | R.drawable.ic_behance,
74 | "Behance",
75 | "120",
76 | "20/3/1993",
77 | "Recieved",
78 | R.drawable.ic_behance
79 | )
80 | )
81 | }
82 |
83 |
84 | private lateinit var mAdapter: AdapterIncome
85 | override fun onCreate(savedInstanceState: Bundle?) {
86 | super.onCreate(savedInstanceState)
87 | setContentView(R.layout.activity_view_transitions)
88 | mAdapter = AdapterIncome(this, items) { income, view ->
89 |
90 | //scaleDownAnimation
91 | val animator = mAdapter.getScaleDownAnimator(false,income)
92 | animator.start()
93 | animator.doOnEnd {
94 |
95 | Intent(this, IncomeDetailsActivity::class.java).apply {
96 | putExtra("item", income)
97 |
98 | val options =
99 | ActivityOptionsCompat.makeSceneTransitionAnimation(
100 | this@TransitionAnimationActivity,
101 | view as CardView,
102 | "income"
103 | )
104 |
105 | startActivity(this, options.toBundle())
106 |
107 | mAdapter.getScaleDownAnimator(true, income).apply {
108 | startDelay = 300L
109 | start()
110 | }
111 | }
112 |
113 | }
114 | }
115 |
116 | recyclerIncome.apply {
117 | adapter = mAdapter
118 | layoutManager = LinearLayoutManager(this@TransitionAnimationActivity)
119 | layoutAnimation =
120 | AnimationUtils.loadLayoutAnimation(
121 | this@TransitionAnimationActivity,
122 | R.anim.layout_animation_fall_down
123 | )
124 |
125 | }
126 |
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/java/com/abualgait/msayed/egdroidathomechallenge/ViewTransformationAnimation.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import android.animation.AnimatorSet
4 | import android.os.Bundle
5 | import android.view.View
6 | import android.view.animation.AccelerateInterpolator
7 | import androidx.appcompat.app.AppCompatActivity
8 | import androidx.core.animation.doOnEnd
9 | import androidx.recyclerview.widget.LinearLayoutManager
10 | import com.abualgait.msayed.egdroidathomechallenge.ArcAnimator.ArcMetric
11 | import com.abualgait.msayed.egdroidathomechallenge.ArcAnimator.ArcUtils
12 | import com.abualgait.msayed.egdroidathomechallenge.ArcAnimator.Side
13 | import kotlinx.android.synthetic.main.activity_view_transformation_animation.*
14 |
15 | class ViewTransformationAnimation : AppCompatActivity() {
16 |
17 | var items = arrayListOf().apply {
18 | add(AlarmItem(timeNow, true, mutableSetOf(1, 3)))
19 | add(AlarmItem(timeNow, false, mutableSetOf(1, 4)))
20 | add(AlarmItem(timeNow, false, mutableSetOf(1, 3)))
21 | add(AlarmItem(timeNow, false, mutableSetOf(1, 2, 3, 4, 5, 6)))
22 | add(AlarmItem(timeNow, true, mutableSetOf(5, 1)))
23 | add(AlarmItem(timeNow, true, mutableSetOf(1)))
24 | }
25 |
26 |
27 | private lateinit var mAdapter: AdapterAlarms
28 | override fun onCreate(savedInstanceState: Bundle?) {
29 | super.onCreate(savedInstanceState)
30 | setContentView(R.layout.activity_view_transformation_animation)
31 |
32 | fabAdd.setOnClickListener {
33 | applayForwardAnimation()
34 | }
35 |
36 |
37 | mAdapter = AdapterAlarms(this, items) { income, view ->
38 |
39 |
40 | }
41 |
42 | recyclerAlrams.apply {
43 | adapter = mAdapter
44 | layoutManager = LinearLayoutManager(this@ViewTransformationAnimation)
45 |
46 |
47 | }
48 | }
49 |
50 | private fun applayForwardAnimation() {
51 |
52 | val recyclerViewAnimator =
53 | getValueAnimator(false, DURATION, 0L, AccelerateInterpolator()) { progress ->
54 | recyclerAlrams.alpha = progress
55 | }
56 |
57 | val recyclerViewAnimatorX =
58 | getValueAnimator(true, DURATION, 0L, AccelerateInterpolator()) { progress ->
59 | recyclerAlrams.translationX = -progress * recyclerAlrams.width / 4
60 | }
61 |
62 |
63 | val set = AnimatorSet()
64 | set.play(recyclerViewAnimator).with(recyclerViewAnimatorX)
65 | set.start()
66 | set.doOnEnd {
67 | recyclerAlrams.hide()
68 | }
69 |
70 |
71 | val endX = containerView.x
72 | val endWidth = containerView.width
73 | val endHeight = containerView.height
74 | var fabx2 = 0f
75 |
76 |
77 | val arcMetric = ArcMetric.evaluate(
78 | fabAdd.x,
79 | fabAdd.y,
80 | frameContainer.width / 2f - fabAdd.width / 2f,
81 | (coordinator.height - frameContainer.height / 2f - fabAdd.height / 2f),
82 | 90f,
83 | Side.RIGHT
84 | )
85 |
86 |
87 | val arcShapeAnimator =
88 | getValueAnimator(true, DURATION, 0L, AccelerateInterpolator()) { progress ->
89 | val degree = arcMetric.getDegree(progress).toDouble()
90 | fabAdd.x = arcMetric.axisPoint.x + arcMetric.mRadius * ArcUtils.cos(degree)
91 | fabAdd.y = arcMetric.axisPoint.y - arcMetric.mRadius * ArcUtils.sin(degree)
92 | }
93 |
94 | arcShapeAnimator.start()
95 |
96 | val circularRevealAnimator =
97 | getValueAnimator(true, DURATION / 2, 0L, AccelerateInterpolator()) { progress ->
98 | if (progress <= 0.8f) {
99 | if (endWidth >= 0) fabAdd.layoutParams.width =
100 | getProgressValue(fabAdd.width * 1f, endWidth * 1f, progress / 0.8f).toInt()
101 | if (endHeight >= 0) fabAdd.layoutParams.height =
102 | getProgressValue(
103 | fabAdd.height * 1f,
104 | endHeight * 1f,
105 | progress / 0.8f
106 | ).toInt()
107 | if (endWidth >= 0 || endHeight >= 0) fabAdd.requestLayout()
108 |
109 | if (endX >= 0) fabAdd.x = getProgressValue(fabx2, endX, progress)
110 |
111 | }
112 | }
113 | circularRevealAnimator.doOnEnd {
114 | containerView.show()
115 | fabAdd.visibility = View.INVISIBLE
116 | }
117 | arcShapeAnimator.doOnEnd {
118 |
119 | fabAdd.setImageDrawable(null)
120 | fabx2 = fabAdd.x
121 |
122 | circularRevealAnimator.start()
123 | }
124 |
125 |
126 | }
127 |
128 | private fun getProgressValue(start: Float, end: Float, progress: Float): Float =
129 | start + (end - start) * progress
130 |
131 | companion object {
132 | val DURATION = 800L
133 |
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/item_animation_fall_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
10 |
11 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/layout_animation_fall_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/color/color_list_day_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/box_ceil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/box_ceil.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/box_floor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/box_floor.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cirle_solid_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cirle_stroke_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/egdroid_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/egdroid_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/frame_gradiant.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_account_balance_wallet_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_drop_down_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_forward_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_behance.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_center_focus_strong_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_favorite_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_favorite_border_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_filter_list_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_google_play.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_message_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_screen_share_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_shop_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_star_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_twitter.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_youtube.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/nike_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/nike_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/profile2020.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/profile2020.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rounded.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shoe1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/shoe1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shoe2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/shoe2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shoe3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/shoe3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shoe4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/drawable/shoe4.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_income_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
19 |
20 |
29 |
30 |
35 |
36 |
42 |
43 |
48 |
49 |
52 |
53 |
58 |
59 |
60 |
64 |
65 |
70 |
71 |
74 |
75 |
76 |
77 |
78 |
79 |
90 |
91 |
92 |
102 |
103 |
115 |
116 |
132 |
133 |
139 |
140 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
19 |
20 |
24 |
25 |
28 |
29 |
33 |
34 |
35 |
39 |
40 |
45 |
46 |
49 |
50 |
56 |
57 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
75 |
76 |
79 |
80 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
104 |
105 |
108 |
109 |
115 |
116 |
123 |
124 |
125 |
126 |
127 |
128 |
133 |
134 |
137 |
138 |
144 |
145 |
152 |
153 |
154 |
155 |
156 |
157 |
161 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_shoe_boxes.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
23 |
24 |
30 |
31 |
36 |
37 |
38 |
39 |
52 |
53 |
54 |
55 |
65 |
66 |
81 |
82 |
94 |
95 |
96 |
97 |
98 |
105 |
106 |
113 |
114 |
115 |
116 |
126 |
127 |
134 |
135 |
136 |
137 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash_screen_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_view_transformation_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
19 |
20 |
21 |
34 |
35 |
46 |
47 |
57 |
58 |
68 |
69 |
70 |
71 |
72 |
81 |
82 |
87 |
88 |
101 |
102 |
106 |
107 |
113 |
114 |
120 |
121 |
122 |
136 |
137 |
150 |
151 |
165 |
166 |
179 |
180 |
194 |
195 |
209 |
210 |
224 |
225 |
231 |
232 |
238 |
239 |
245 |
246 |
252 |
253 |
254 |
266 |
267 |
277 |
278 |
287 |
288 |
297 |
298 |
302 |
303 |
310 |
311 |
318 |
319 |
320 |
321 |
331 |
332 |
336 |
337 |
344 |
345 |
352 |
353 |
354 |
355 |
369 |
370 |
374 |
375 |
382 |
383 |
390 |
391 |
392 |
393 |
394 |
395 |
405 |
406 |
414 |
415 |
416 |
417 |
429 |
430 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_view_transitions.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
20 |
21 |
22 |
23 |
28 |
29 |
32 |
33 |
37 |
38 |
42 |
43 |
47 |
48 |
52 |
53 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_alarm.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
29 |
30 |
44 |
45 |
59 |
60 |
74 |
75 |
89 |
90 |
104 |
105 |
119 |
120 |
131 |
132 |
142 |
143 |
152 |
153 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_income.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
21 |
22 |
32 |
33 |
39 |
40 |
46 |
47 |
53 |
54 |
60 |
61 |
73 |
74 |
85 |
86 |
97 |
98 |
109 |
110 |
118 |
119 |
127 |
128 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
27 |
28 |
34 |
35 |
45 |
46 |
56 |
57 |
69 |
70 |
79 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_shoe.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
22 |
33 |
34 |
46 |
47 |
59 |
60 |
72 |
73 |
85 |
86 |
87 |
98 |
99 |
110 |
111 |
121 |
122 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/income.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #FFEE4D
6 | #CCCCCC
7 | #333333
8 | #008CFF
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8sp
4 | 30dp
5 | 30dp
6 | 60dp
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EgDroidAtHomeChallenge
3 | egdroid challenge
4 | day
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
20 |
21 |
22 |
26 |
27 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/test/java/com/abualgait/msayed/egdroidathomechallenge/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.abualgait.msayed.egdroidathomechallenge
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.61'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.6.1'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 |
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Apr 13 10:38:13 EET 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='EgDroidAtHomeChallenge'
2 | include ':app'
3 |
--------------------------------------------------------------------------------
/shoe boxes animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/shoe boxes animation.gif
--------------------------------------------------------------------------------
/splah_screen_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/splah_screen_gif.gif
--------------------------------------------------------------------------------
/transition_animation_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/transition_animation_gif.gif
--------------------------------------------------------------------------------
/view_tansformation_gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeAreEGDroid/animation-challenge/a5d521b82376137e863ea8ec62ab7587ed5317db/view_tansformation_gif.gif
--------------------------------------------------------------------------------