From 26b99f5f68ce92d2a2e6d3dae526c9c51f4f8dbf Mon Sep 17 00:00:00 2001 From: Grishka Date: Tue, 17 Oct 2023 04:31:07 +0300 Subject: [PATCH] =?UTF-8?q?New=20and=20improved=E2=84=A2=20"new=20posts"?= =?UTF-8?q?=20button=20(AND-102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fragments/HomeTimelineFragment.java | 95 ++++++++----------- mastodon/src/main/res/animator/squish.xml | 47 +++++++++ .../main/res/drawable/bg_button_new_posts.xml | 10 -- .../res/drawable/ic_arrow_upward_24px.xml | 9 ++ .../drawable/ic_fluent_arrow_up_16_filled.xml | 3 - ...ys_motion_easing_emphasized_accelerate.xml | 22 +++++ ..._sys_motion_easing_standard_accelerate.xml | 22 +++++ .../src/main/res/layout/fragment_timeline.xml | 57 +++++++++++ mastodon/src/main/res/values/strings.xml | 2 +- mastodon/src/main/res/values/tokens.xml | 5 + 10 files changed, 203 insertions(+), 69 deletions(-) create mode 100644 mastodon/src/main/res/animator/squish.xml delete mode 100644 mastodon/src/main/res/drawable/bg_button_new_posts.xml create mode 100644 mastodon/src/main/res/drawable/ic_arrow_upward_24px.xml delete mode 100644 mastodon/src/main/res/drawable/ic_fluent_arrow_up_16_filled.xml create mode 100644 mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_emphasized_accelerate.xml create mode 100644 mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_standard_accelerate.xml create mode 100644 mastodon/src/main/res/layout/fragment_timeline.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java index 5307abf56..7c10eb5ed 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -4,10 +4,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.animation.StateListAnimator; import android.app.Activity; import android.content.res.Configuration; -import android.os.Build; import android.os.Bundle; +import android.util.Log; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; @@ -15,6 +16,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; +import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageButton; @@ -42,7 +44,6 @@ import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.TimelineMarkers; import org.joinmastodon.android.ui.displayitems.GapStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; -import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.viewcontrollers.HomeTimelineMenuController; import org.joinmastodon.android.ui.viewcontrollers.ToolbarDropdownMenuController; import org.joinmastodon.android.ui.views.FixedAspectRatioImageView; @@ -68,7 +69,8 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD private LinearLayout listsDropdown; private FixedAspectRatioImageView listsDropdownArrow; private TextView listsDropdownText; - private Button toolbarShowNewPostsBtn; + private Button newPostsBtn; + private StateListAnimator newPostsBtnStateAnimator; private boolean newPostsBtnShown; private AnimatorSet currentNewPostsAnim; private ToolbarDropdownMenuController dropdownController; @@ -81,7 +83,7 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD private String lastSavedMarkerID; public HomeTimelineFragment(){ - setListLayoutId(R.layout.recycler_fragment_with_fab); + setListLayoutId(R.layout.fragment_timeline); } @Override @@ -191,6 +193,20 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD super.onViewCreated(view, savedInstanceState); fab=view.findViewById(R.id.fab); fab.setOnClickListener(this::onFabClick); + newPostsBtn=view.findViewById(R.id.new_posts_btn); + newPostsBtn.setOnClickListener(this::onNewPostsBtnClick); + newPostsBtnStateAnimator=newPostsBtn.getStateListAnimator(); + + if(newPostsBtnShown){ + newPostsBtn.setVisibility(View.VISIBLE); + }else{ + newPostsBtn.setVisibility(View.GONE); + newPostsBtn.setStateListAnimator(null); + newPostsBtn.setScaleX(0.9f); + newPostsBtn.setScaleY(0.9f); + newPostsBtn.setAlpha(0f); + newPostsBtn.setTranslationY(V.dp(-56)); + } updateToolbarLogo(); list.addOnScrollListener(new RecyclerView.OnScrollListener(){ @Override @@ -467,44 +483,10 @@ public class HomeTimelineFragment extends StatusListFragment implements ToolbarD listsDropdown.setBackgroundTintList(listsDropdownText.getTextColors()); listsDropdown.addView(listsDropdownText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); - toolbarShowNewPostsBtn=new Button(getActivity()); - toolbarShowNewPostsBtn.setTextAppearance(R.style.m3_title_medium); - toolbarShowNewPostsBtn.setTextColor(0xffffffff); - toolbarShowNewPostsBtn.setStateListAnimator(null); - toolbarShowNewPostsBtn.setBackgroundResource(R.drawable.bg_button_new_posts); - toolbarShowNewPostsBtn.setText(R.string.see_new_posts); - toolbarShowNewPostsBtn.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_fluent_arrow_up_16_filled, 0, 0, 0); - toolbarShowNewPostsBtn.setCompoundDrawableTintList(toolbarShowNewPostsBtn.getTextColors()); - toolbarShowNewPostsBtn.setCompoundDrawablePadding(V.dp(8)); - if(Build.VERSION.SDK_INT + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/bg_button_new_posts.xml b/mastodon/src/main/res/drawable/bg_button_new_posts.xml deleted file mode 100644 index 2178510e4..000000000 --- a/mastodon/src/main/res/drawable/bg_button_new_posts.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/ic_arrow_upward_24px.xml b/mastodon/src/main/res/drawable/ic_arrow_upward_24px.xml new file mode 100644 index 000000000..15d81d9d6 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_arrow_upward_24px.xml @@ -0,0 +1,9 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_arrow_up_16_filled.xml b/mastodon/src/main/res/drawable/ic_fluent_arrow_up_16_filled.xml deleted file mode 100644 index 39a248513..000000000 --- a/mastodon/src/main/res/drawable/ic_fluent_arrow_up_16_filled.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_emphasized_accelerate.xml b/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_emphasized_accelerate.xml new file mode 100644 index 000000000..2527b6607 --- /dev/null +++ b/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_emphasized_accelerate.xml @@ -0,0 +1,22 @@ + + + + diff --git a/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_standard_accelerate.xml b/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_standard_accelerate.xml new file mode 100644 index 000000000..513147958 --- /dev/null +++ b/mastodon/src/main/res/interpolator-v21/m3_sys_motion_easing_standard_accelerate.xml @@ -0,0 +1,22 @@ + + + + diff --git a/mastodon/src/main/res/layout/fragment_timeline.xml b/mastodon/src/main/res/layout/fragment_timeline.xml new file mode 100644 index 000000000..9a6c457e4 --- /dev/null +++ b/mastodon/src/main/res/layout/fragment_timeline.xml @@ -0,0 +1,57 @@ + + + + + + + + + + +