Skip to content

Commit

Permalink
made visual changes to the loading indicator in the feed
Browse files Browse the repository at this point in the history
  • Loading branch information
zaguragit committed Jul 9, 2020
1 parent 8bc6f80 commit 46df38e
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 67 deletions.
19 changes: 14 additions & 5 deletions app/src/main/java/posidon/launcher/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ class Main : AppCompatActivity() {
findViewById<View>(R.id.drawercontent).layoutParams.height = metrics.heightPixels
(findViewById<View>(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<View>(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<View>(R.id.desktopContent).setPadding(0, 6.dp.toInt(), 0, 24.dp.toInt())
}
if (Settings["dock:background_type", 0] == 1) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -709,7 +711,7 @@ class Main : AppCompatActivity() {
layoutManager = LinearLayoutManager(this@Main)
isNestedScrollingEnabled = false
}
feedProgressBar = findViewById<ProgressBar>(R.id.feedProgressBar)
feedProgressBar = findViewById(R.id.feedProgressBar)
loadFeed()

notifications = findViewById<RecyclerView>(R.id.notifications).apply {
Expand Down Expand Up @@ -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<FeedItem>) {
(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()
}
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/drawable/progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<vector
android:width="64dp"
android:height="64dp"
android:viewportWidth="67.73333"
android:viewportHeight="67.73334">
<path
android:pathData="M33.8667,33.8667m-33.8667,0a33.8667,33.8667 0,1 1,67.7333 0a33.8667,33.8667 0,1 1,-67.7333 0"
android:fillColor="#545556"
android:fillAlpha="0.8"/>
<path
android:pathData="m33.8667,6.5128c7.5536,0 14.392,3.0617 19.3421,8.0118 4.9501,4.9501 8.0118,11.7885 8.0118,19.3421 0,7.5536 -3.0617,14.392 -8.0118,19.3421"
android:strokeWidth="4.55897"
android:strokeColor="#fff"
android:strokeLineCap="round"/>
<path
android:pathData="M33.8506,12.7A21.1667,21.1667 0,0 0,12.7 33.8667A21.1667,21.1667 0,0 0,33.8667 55.0333A21.1667,21.1667 0,0 0,55.0333 33.8667A21.1667,21.1667 0,0 0,33.8667 12.7A21.1667,21.1667 0,0 0,33.8506 12.7zM33.7881,16.9333A16.9333,16.9333 0,0 1,33.8667 16.9333A16.9333,16.9333 0,0 1,50.8 33.8667A16.9333,16.9333 0,0 1,33.8667 50.8A16.9333,16.9333 0,0 1,16.9333 33.8667A16.9333,16.9333 0,0 1,33.7881 16.9333z"
android:fillColor="#fff"/>
</vector>
</rotate>
121 changes: 59 additions & 62 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,77 +25,74 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/desktopContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">


<posidon.launcher.view.ResizableLayout
android:id="@+id/widgets"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include
android:id="@+id/musicCard"
android:visibility="gone"
layout="@layout/music_card"
android:id="@+id/desktopContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="9dp"/>
<LinearLayout
android:id="@+id/parentNotification"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginTop="9dp"
android:layout_marginBottom="9dp"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:id="@+id/arrowUp"
android:orientation="vertical">
<posidon.launcher.view.ResizableLayout
android:id="@+id/widgets"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include
android:id="@+id/musicCard"
android:visibility="gone"
layout="@layout/music_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="9dp"/>
<LinearLayout
android:id="@+id/parentNotification"
android:layout_width="match_parent"
android:layout_height="48dp"
android:src="@drawable/arrow_up"
android:layout_height="72dp"
android:layout_marginTop="9dp"
android:layout_marginBottom="9dp"
android:orientation="horizontal"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:id="@+id/arrowUp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:src="@drawable/arrow_up"
android:visibility="gone"/>
<TextView
android:id="@+id/parentNotificationTitle"
android:layout_width="0dp"
android:layout_height="48dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="17sp"/>
<ImageView
android:id="@+id/parentNotificationBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_notification"
android:background="@drawable/button_bg_round"
android:padding="8dp"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notifications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView
android:id="@+id/parentNotificationTitle"
android:layout_width="0dp"
android:layout_height="48dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="17sp"/>
<ImageView
android:id="@+id/parentNotificationBtn"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_notification"
android:background="@drawable/button_bg_round"
android:padding="8dp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/feedrecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notifications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/feedrecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<ProgressBar
android:id="@+id/feedProgressBar"
style="?android:attr/progressBarStyleLarge"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="72dp"
android:indeterminateTint="@color/accent"
android:indeterminateTintMode="src_atop"
android:visibility="gone" />
android:layout_height="64dp"
android:layout_marginTop="72dp"
android:indeterminateDrawable="@drawable/progress"
android:indeterminateDuration="500"
android:indeterminateTintMode="multiply"
android:visibility="gone"/>
</RelativeLayout>
</posidon.launcher.view.NestedScrollView>

Expand Down

0 comments on commit 46df38e

Please sign in to comment.