From f696b6e8d35ce3cb62ec7d63632abc59975aa84f Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sat, 5 Aug 2017 11:34:50 +0200 Subject: [PATCH] bugfix, layout improvements --- .../keylesspalace/tusky/AccountActivity.java | 14 +- .../tusky/fragment/AccountListFragment.java | 7 +- .../tusky/fragment/NotificationsFragment.java | 8 +- .../tusky/fragment/TimelineFragment.java | 7 +- .../interfaces/ActionButtonActivity.java | 2 + app/src/main/res/layout/activity_account.xml | 160 +++++++++--------- 6 files changed, 102 insertions(+), 96 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 3c2fec8b..103bfb10 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -166,7 +166,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute); } - if(floatingBtn != null && hideFab) { + if(floatingBtn != null && hideFab && !isSelf && !blocking) { if (verticalOffset > oldOffset) { floatingBtn.show(); } @@ -367,10 +367,6 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit this.blocking = relation.blocking; this.muting = relation.muting; - if (followState != FollowState.NOT_FOLLOWING || !blocking || !muting) { - invalidateOptionsMenu(); - } - if(relation.followedBy) { followsYouView.setVisibility(View.VISIBLE); } else { @@ -424,6 +420,9 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit updateFollowButton(followBtn); } }); + } else { + floatingBtn.hide(); + followBtn.setVisibility(View.GONE); } } @@ -668,7 +667,10 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit @Nullable @Override public FloatingActionButton getActionButton() { - return floatingBtn; + if(!isSelf && !blocking) { + return floatingBtn; + } + return null; } } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java index 996c4206..a3f81c0d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java @@ -178,15 +178,16 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi if (actionButtonPresent()) { /* Use a modified scroll listener that both loads more statuses as it goes, and hides * the follow button on down-scroll. */ - ActionButtonActivity actionButtonActivity = (ActionButtonActivity) getActivity(); - final FloatingActionButton composeButton = actionButtonActivity.getActionButton(); - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); hideFab = preferences.getBoolean("fabHide", false); scrollListener = new EndlessOnScrollListener(layoutManager) { @Override public void onScrolled(RecyclerView view, int dx, int dy) { super.onScrolled(view, dx, dy); + ActionButtonActivity actionButtonActivity = (ActionButtonActivity) getActivity(); + FloatingActionButton composeButton = actionButtonActivity.getActionButton(); + if (composeButton != null) { if (hideFab) { if (dy > 0 && composeButton.isShown()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 8375bf86..f4de5665 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -40,6 +40,7 @@ import com.keylesspalace.tusky.adapter.NotificationsAdapter; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Status; +import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.util.HttpHeaderLink; @@ -172,9 +173,7 @@ public class NotificationsFragment extends SFragment implements * guaranteed to be set until then. * Use a modified scroll listener that both loads more notifications as it goes, and hides * the compose button on down-scroll. */ - final FloatingActionButton composeButton = activity.getActionButton(); - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences( - activity); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); preferences.registerOnSharedPreferenceChangeListener(this); hideFab = preferences.getBoolean("fabHide", false); scrollListener = new EndlessOnScrollListener(layoutManager) { @@ -182,6 +181,9 @@ public class NotificationsFragment extends SFragment implements public void onScrolled(RecyclerView view, int dx, int dy) { super.onScrolled(view, dx, dy); + ActionButtonActivity activity = (ActionButtonActivity) getActivity(); + FloatingActionButton composeButton = activity.getActionButton(); + if(composeButton != null) { if (hideFab) { if (dy > 0 && composeButton.isShown()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index 379b9c42..103f7e81 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -198,15 +198,16 @@ public class TimelineFragment extends SFragment implements if (actionButtonPresent()) { /* Use a modified scroll listener that both loads more statuses as it goes, and hides * the follow button on down-scroll. */ - ActionButtonActivity activity = (ActionButtonActivity) getActivity(); - final FloatingActionButton composeButton = activity.getActionButton(); - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); hideFab = preferences.getBoolean("fabHide", false); scrollListener = new EndlessOnScrollListener(layoutManager) { @Override public void onScrolled(RecyclerView view, int dx, int dy) { super.onScrolled(view, dx, dy); + ActionButtonActivity activity = (ActionButtonActivity) getActivity(); + FloatingActionButton composeButton = activity.getActionButton(); + if (composeButton != null) { if (hideFab) { if (dy > 0 && composeButton.isShown()) { diff --git a/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java b/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java index 35d2b9c0..faf2352d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java @@ -19,6 +19,8 @@ import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; public interface ActionButtonActivity { + + /* return the ActionButton of the Activity to hide or show it on scroll */ @Nullable FloatingActionButton getActionButton(); } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index bd1ecce0..a1788cb4 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -1,6 +1,7 @@ - - + +