bugfix, layout improvements

This commit is contained in:
Conny Duck 2017-08-05 11:34:50 +02:00
parent 2f66de9797
commit f696b6e8d3
6 changed files with 102 additions and 96 deletions

View File

@ -166,7 +166,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit
ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute); ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute);
} }
if(floatingBtn != null && hideFab) { if(floatingBtn != null && hideFab && !isSelf && !blocking) {
if (verticalOffset > oldOffset) { if (verticalOffset > oldOffset) {
floatingBtn.show(); floatingBtn.show();
} }
@ -367,10 +367,6 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit
this.blocking = relation.blocking; this.blocking = relation.blocking;
this.muting = relation.muting; this.muting = relation.muting;
if (followState != FollowState.NOT_FOLLOWING || !blocking || !muting) {
invalidateOptionsMenu();
}
if(relation.followedBy) { if(relation.followedBy) {
followsYouView.setVisibility(View.VISIBLE); followsYouView.setVisibility(View.VISIBLE);
} else { } else {
@ -424,6 +420,9 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit
updateFollowButton(followBtn); updateFollowButton(followBtn);
} }
}); });
} else {
floatingBtn.hide();
followBtn.setVisibility(View.GONE);
} }
} }
@ -668,7 +667,10 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit
@Nullable @Nullable
@Override @Override
public FloatingActionButton getActionButton() { public FloatingActionButton getActionButton() {
return floatingBtn; if(!isSelf && !blocking) {
return floatingBtn;
}
return null;
} }
} }

View File

@ -178,15 +178,16 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi
if (actionButtonPresent()) { if (actionButtonPresent()) {
/* Use a modified scroll listener that both loads more statuses as it goes, and hides /* Use a modified scroll listener that both loads more statuses as it goes, and hides
* the follow button on down-scroll. */ * the follow button on down-scroll. */
ActionButtonActivity actionButtonActivity = (ActionButtonActivity) getActivity(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
final FloatingActionButton composeButton = actionButtonActivity.getActionButton();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
hideFab = preferences.getBoolean("fabHide", false); hideFab = preferences.getBoolean("fabHide", false);
scrollListener = new EndlessOnScrollListener(layoutManager) { scrollListener = new EndlessOnScrollListener(layoutManager) {
@Override @Override
public void onScrolled(RecyclerView view, int dx, int dy) { public void onScrolled(RecyclerView view, int dx, int dy) {
super.onScrolled(view, dx, dy); super.onScrolled(view, dx, dy);
ActionButtonActivity actionButtonActivity = (ActionButtonActivity) getActivity();
FloatingActionButton composeButton = actionButtonActivity.getActionButton();
if (composeButton != null) { if (composeButton != null) {
if (hideFab) { if (hideFab) {
if (dy > 0 && composeButton.isShown()) { if (dy > 0 && composeButton.isShown()) {

View File

@ -40,6 +40,7 @@ import com.keylesspalace.tusky.adapter.NotificationsAdapter;
import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.entity.Notification; import com.keylesspalace.tusky.entity.Notification;
import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.entity.Status;
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.interfaces.StatusActionListener;
import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.receiver.TimelineReceiver;
import com.keylesspalace.tusky.util.HttpHeaderLink; import com.keylesspalace.tusky.util.HttpHeaderLink;
@ -172,9 +173,7 @@ public class NotificationsFragment extends SFragment implements
* guaranteed to be set until then. * guaranteed to be set until then.
* Use a modified scroll listener that both loads more notifications as it goes, and hides * Use a modified scroll listener that both loads more notifications as it goes, and hides
* the compose button on down-scroll. */ * the compose button on down-scroll. */
final FloatingActionButton composeButton = activity.getActionButton(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(
activity);
preferences.registerOnSharedPreferenceChangeListener(this); preferences.registerOnSharedPreferenceChangeListener(this);
hideFab = preferences.getBoolean("fabHide", false); hideFab = preferences.getBoolean("fabHide", false);
scrollListener = new EndlessOnScrollListener(layoutManager) { scrollListener = new EndlessOnScrollListener(layoutManager) {
@ -182,6 +181,9 @@ public class NotificationsFragment extends SFragment implements
public void onScrolled(RecyclerView view, int dx, int dy) { public void onScrolled(RecyclerView view, int dx, int dy) {
super.onScrolled(view, dx, dy); super.onScrolled(view, dx, dy);
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
FloatingActionButton composeButton = activity.getActionButton();
if(composeButton != null) { if(composeButton != null) {
if (hideFab) { if (hideFab) {
if (dy > 0 && composeButton.isShown()) { if (dy > 0 && composeButton.isShown()) {

View File

@ -198,15 +198,16 @@ public class TimelineFragment extends SFragment implements
if (actionButtonPresent()) { if (actionButtonPresent()) {
/* Use a modified scroll listener that both loads more statuses as it goes, and hides /* Use a modified scroll listener that both loads more statuses as it goes, and hides
* the follow button on down-scroll. */ * the follow button on down-scroll. */
ActionButtonActivity activity = (ActionButtonActivity) getActivity(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
final FloatingActionButton composeButton = activity.getActionButton();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
hideFab = preferences.getBoolean("fabHide", false); hideFab = preferences.getBoolean("fabHide", false);
scrollListener = new EndlessOnScrollListener(layoutManager) { scrollListener = new EndlessOnScrollListener(layoutManager) {
@Override @Override
public void onScrolled(RecyclerView view, int dx, int dy) { public void onScrolled(RecyclerView view, int dx, int dy) {
super.onScrolled(view, dx, dy); super.onScrolled(view, dx, dy);
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
FloatingActionButton composeButton = activity.getActionButton();
if (composeButton != null) { if (composeButton != null) {
if (hideFab) { if (hideFab) {
if (dy > 0 && composeButton.isShown()) { if (dy > 0 && composeButton.isShown()) {

View File

@ -19,6 +19,8 @@ import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
public interface ActionButtonActivity { public interface ActionButtonActivity {
/* return the ActionButton of the Activity to hide or show it on scroll */
@Nullable @Nullable
FloatingActionButton getActionButton(); FloatingActionButton getActionButton();
} }

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_account" android:id="@+id/activity_account"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -39,100 +40,97 @@
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:layout_collapseMode="pin" /> app:layout_collapseMode="pin" />
<LinearLayout <RelativeLayout
android:id="@+id/account_header_info" android:id="@+id/account_header_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/account_header_gradient" android:background="@drawable/account_header_gradient"
android:orientation="vertical" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="?attr/actionBarSize" android:paddingTop="?attr/actionBarSize"
app:layout_collapseMode="parallax"> app:layout_collapseMode="parallax">
<RelativeLayout <com.pkmmte.view.CircularImageView
android:id="@+id/account_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/follow_btn"
android:layout_toStartOf="@+id/follow_btn"
android:src="@drawable/avatar_default"
app:shadow="true" />
<Button
android:id="@+id/follow_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="6dp" />
<TextView
android:id="@+id/account_follows_you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/follow_btn"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/follows_you"
android:textColor="?android:textColorPrimary" />
<TextView
android:id="@+id/account_display_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="16dp" android:layout_below="@id/account_avatar"
android:paddingRight="16dp"> android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="18sp"
android:textStyle="normal|bold"
tools:text="Tusky Mastodon Client" />
<com.pkmmte.view.CircularImageView <TextView
android:id="@+id/account_avatar" android:id="@+id/account_username"
android:layout_width="80dp" android:layout_width="wrap_content"
android:layout_height="80dp" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_below="@id/account_display_name"
android:layout_alignParentStart="true" android:ellipsize="end"
android:layout_marginEnd="10dp" android:maxLines="1"
android:layout_marginRight="10dp" android:textColor="?android:textColorSecondary"
android:layout_toLeftOf="@+id/follow_btn" tools:text="\@Tusky" />
android:layout_toStartOf="@+id/follow_btn"
android:src="@drawable/avatar_default"
app:shadow="true" />
<Button <ImageView
android:id="@+id/follow_btn" android:id="@+id/account_locked"
android:layout_width="wrap_content" android:layout_width="16sp"
android:layout_height="wrap_content" android:layout_height="16sp"
android:layout_alignParentEnd="true" android:layout_alignBottom="@id/account_username"
android:layout_alignParentRight="true" android:layout_centerVertical="true"
android:layout_marginTop="6dp" /> android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
<TextView android:layout_toEndOf="@id/account_username"
android:id="@+id/account_follows_you" android:layout_toRightOf="@id/account_username"
android:layout_width="wrap_content" android:contentDescription="@string/description_account_locked"
android:layout_height="wrap_content" android:tint="?android:textColorSecondary"
android:layout_alignParentEnd="true" android:visibility="gone"
android:layout_alignParentRight="true" app:srcCompat="@drawable/reblog_disabled_light" />
android:layout_below="@id/follow_btn"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/follows_you"
android:textColor="?android:textColorPrimary" />
<TextView
android:id="@+id/account_display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/account_avatar"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="18sp"
android:textStyle="normal|bold" />
<TextView
android:id="@+id/account_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/account_display_name"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary" />
<ImageView
android:id="@+id/account_locked"
android:layout_width="16sp"
android:layout_height="16sp"
android:layout_alignBaseline="@+id/account_username"
android:layout_centerVertical="true"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_toEndOf="@id/account_username"
android:layout_toRightOf="@id/account_username"
android:contentDescription="@string/description_account_locked"
android:tint="?android:textColorSecondary"
android:visibility="gone"
app:srcCompat="@drawable/reblog_disabled_light" />
</RelativeLayout>
<TextView <TextView
android:id="@+id/account_note" android:id="@+id/account_note"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:layout_below="@id/account_username"
android:paddingBottom="16dp"
android:paddingTop="10dp" android:paddingTop="10dp"
android:textColor="?android:textColorTertiary" /> android:textColor="?android:textColorTertiary"
tools:text="This is a test description" />
</LinearLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
@ -179,11 +177,6 @@
</android.support.v4.view.ViewPager> </android.support.v4.view.ViewPager>
<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<View <View
android:id="@+id/tab_bottom_shadow" android:id="@+id/tab_bottom_shadow"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -202,4 +195,9 @@
android:contentDescription="@string/action_mention" android:contentDescription="@string/action_mention"
app:srcCompat="@drawable/ic_create_24dp" /> app:srcCompat="@drawable/ic_create_24dp" />
<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>