From 46df38e541f092f36600a7c1ebf9ac70f4f9007d Mon Sep 17 00:00:00 2001 From: Zagura Date: Thu, 9 Jul 2020 11:31:43 +0200 Subject: [PATCH] made visual changes to the loading indicator in the feed --- app/src/main/java/posidon/launcher/Main.kt | 19 +++- app/src/main/res/drawable/progress.xml | 25 +++++ app/src/main/res/layout/main.xml | 121 ++++++++++----------- 3 files changed, 98 insertions(+), 67 deletions(-) create mode 100644 app/src/main/res/drawable/progress.xml diff --git a/app/src/main/java/posidon/launcher/Main.kt b/app/src/main/java/posidon/launcher/Main.kt index e6bf48bd..8738c4fc 100644 --- a/app/src/main/java/posidon/launcher/Main.kt +++ b/app/src/main/java/posidon/launcher/Main.kt @@ -242,10 +242,10 @@ class Main : AppCompatActivity() { findViewById(R.id.drawercontent).layoutParams.height = metrics.heightPixels (findViewById(R.id.homeView).layoutParams as FrameLayout.LayoutParams).topMargin = -dockHeight if (Settings["feed:show_behind_dock", false]) { - (desktop.layoutParams as CoordinatorLayout.LayoutParams).setMargins(0, dockHeight, 0, 0) + (desktop.layoutParams as ViewGroup.MarginLayoutParams).setMargins(0, dockHeight, 0, 0) findViewById(R.id.desktopContent).setPadding(0, 0, 0, (dockHeight + Tools.navbarHeight + Settings["dockbottompadding", 10].dp).toInt()) } else { - (desktop.layoutParams as CoordinatorLayout.LayoutParams).setMargins(0, dockHeight, 0, dockHeight + Tools.navbarHeight + (Settings["dockbottompadding", 10] - 18).dp.toInt()) + (desktop.layoutParams as ViewGroup.MarginLayoutParams).setMargins(0, dockHeight, 0, dockHeight + Tools.navbarHeight + (Settings["dockbottompadding", 10] - 18).dp.toInt()) findViewById(R.id.desktopContent).setPadding(0, 6.dp.toInt(), 0, 24.dp.toInt()) } if (Settings["dock:background_type", 0] == 1) { @@ -357,6 +357,8 @@ class Main : AppCompatActivity() { drawerGrid.numColumns = Settings["drawer:columns", 4] drawerGrid.verticalSpacing = Settings["verticalspacing", 12].dp.toInt() } + + feedProgressBar.indeterminateDrawable.setTint(accentColor) val marginX = Settings["feed:card_margin_x", 16].dp.toInt() if (Settings["feed:enabled", true]) { feedRecycler.visibility = VISIBLE @@ -709,7 +711,7 @@ class Main : AppCompatActivity() { layoutManager = LinearLayoutManager(this@Main) isNestedScrollingEnabled = false } - feedProgressBar = findViewById(R.id.feedProgressBar) + feedProgressBar = findViewById(R.id.feedProgressBar) loadFeed() notifications = findViewById(R.id.notifications).apply { @@ -869,17 +871,24 @@ class Main : AppCompatActivity() { fun updateFeed() { if (feedProgressBar.visibility == VISIBLE || !Settings["feed:enabled", true]) return feedProgressBar.visibility = VISIBLE + feedProgressBar.animate().translationY(0f).alpha(1f).setListener(null) FeedLoader(object : FeedLoader.Listener { override fun onFinished(feedModels: ArrayList) { (feedRecycler.adapter as FeedAdapter).updateFeed(feedModels) - feedProgressBar.visibility = GONE + feedProgressBar.animate().translationY(-72.dp).alpha(0f).setListener(object : Animator.AnimatorListener { + override fun onAnimationRepeat(animation: Animator?) {} + override fun onAnimationCancel(animation: Animator?) {} + override fun onAnimationStart(animation: Animator?) {} + override fun onAnimationEnd(animation: Animator?) { + feedProgressBar.visibility = GONE + } + }) } }).execute() } private fun loadFeed() { if (Settings["feed:enabled", true]) { - feedProgressBar.indeterminateDrawable.setColorFilter(accentColor, PorterDuff.Mode.SRC_IN ) feedRecycler.adapter = FeedAdapter(ArrayList(), this@Main) updateFeed() } diff --git a/app/src/main/res/drawable/progress.xml b/app/src/main/res/drawable/progress.xml new file mode 100644 index 00000000..55ccba32 --- /dev/null +++ b/app/src/main/res/drawable/progress.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index 035a6793..a01096bc 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -25,77 +25,74 @@ - - - - - - - + + + + + + + + - - + - - - - + android:layout_height="64dp" + android:layout_marginTop="72dp" + android:indeterminateDrawable="@drawable/progress" + android:indeterminateDuration="500" + android:indeterminateTintMode="multiply" + android:visibility="gone"/>