From 42734c4f5712ce37a54ddd896fb1d501371959e7 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Thu, 3 Aug 2017 16:24:14 +0200 Subject: [PATCH 1/7] improve layout of AccountActivity tabs --- app/src/main/res/color/account_tab_font_color.xml | 5 +++++ app/src/main/res/layout/activity_account.xml | 3 ++- app/src/main/res/layout/tab_account.xml | 15 ++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/color/account_tab_font_color.xml diff --git a/app/src/main/res/color/account_tab_font_color.xml b/app/src/main/res/color/account_tab_font_color.xml new file mode 100644 index 00000000..accc21cb --- /dev/null +++ b/app/src/main/res/color/account_tab_font_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index ee853c1e..8abfa16c 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -150,7 +150,8 @@ android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - app:tabBackground="?android:colorBackground"> + app:tabBackground="?android:colorBackground" + app:tabGravity="fill"> - + android:layout_centerHorizontal="true" + android:textColor="@color/account_tab_font_color" + android:textSize="12sp" /> \ No newline at end of file From e4c9b229d707f22202952cf564de5ebddc8cbc14 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Fri, 4 Aug 2017 10:53:38 +0200 Subject: [PATCH 2/7] change floating action button to "mention", create new follow button in AccountActivity --- .../keylesspalace/tusky/AccountActivity.java | 50 ++++++++++++------- app/src/main/res/layout/activity_account.xml | 23 ++++++--- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index bc3a0233..53d723b8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -41,6 +41,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; @@ -81,6 +82,7 @@ public class AccountActivity extends BaseActivity { private CircularImageView avatar; private ImageView header; private FloatingActionButton floatingBtn; + private Button followBtn; private TabLayout tabLayout; private ImageView accountLockedView; private View container; @@ -93,6 +95,7 @@ public class AccountActivity extends BaseActivity { avatar = (CircularImageView) findViewById(R.id.account_avatar); header = (ImageView) findViewById(R.id.account_header); floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); + followBtn = (Button) findViewById(R.id.follow_btn); tabLayout = (TabLayout) findViewById(R.id.tab_layout); accountLockedView = (ImageView) findViewById(R.id.account_locked); container = findViewById(R.id.activity_account); @@ -160,6 +163,7 @@ public class AccountActivity extends BaseActivity { // Initialise the default UI states. floatingBtn.hide(); + followBtn.setVisibility(View.GONE); // Obtain information to fill out the profile. obtainAccount(); @@ -354,21 +358,18 @@ public class AccountActivity extends BaseActivity { updateButtons(); } - private void updateFollowButton(FloatingActionButton button) { + private void updateFollowButton(Button button) { switch (followState) { case NOT_FOLLOWING: { - button.setImageResource(R.drawable.ic_person_add_24dp); - button.setContentDescription(getString(R.string.action_follow)); + button.setText(getString(R.string.action_follow)); break; } case REQUESTED: { - button.setImageResource(R.drawable.ic_hourglass_24dp); - button.setContentDescription(getString(R.string.state_follow_requested)); + button.setText(getString(R.string.state_follow_requested)); break; } case FOLLOWING: { - button.setImageResource(R.drawable.ic_person_minus_24px); - button.setContentDescription(getString(R.string.action_unfollow)); + button.setText(getString(R.string.action_unfollow)); break; } } @@ -379,18 +380,26 @@ public class AccountActivity extends BaseActivity { if(!isSelf && !blocking) { floatingBtn.show(); + followBtn.setVisibility(View.VISIBLE); - updateFollowButton(floatingBtn); + updateFollowButton(followBtn); floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (followState != FollowState.REQUESTED) { + mention(); + } + }); + + followBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (followState != FollowState.REQUESTED) { follow(accountId); } else { showFollowRequestPendingDialog(accountId); } - updateFollowButton(floatingBtn); + updateFollowButton(followBtn); } }); } @@ -543,7 +552,6 @@ public class AccountActivity extends BaseActivity { .show(); } - private void mute(final String id) { Callback cb = new Callback() { @Override @@ -582,6 +590,17 @@ public class AccountActivity extends BaseActivity { .show(); } + private boolean mention() { + if (loadedAccount == null) { + // If the account isn't loaded yet, eat the input. + return false; + } + Intent intent = new Intent(this, ComposeActivity.class); + intent.putExtra("mentioned_usernames", new String[] { loadedAccount.username }); + startActivity(intent); + return true; + } + private void broadcast(String action, String id) { Intent intent = new Intent(action); intent.putExtra("id", id); @@ -596,14 +615,7 @@ public class AccountActivity extends BaseActivity { return true; } case R.id.action_mention: { - if (loadedAccount == null) { - // If the account isn't loaded yet, eat the input. - return false; - } - Intent intent = new Intent(this, ComposeActivity.class); - intent.putExtra("mentioned_usernames", new String[] { loadedAccount.username }); - startActivity(intent); - return true; + return mention(); } case R.id.action_open_in_web: { if (loadedAccount == null) { diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 8abfa16c..ca81039a 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -52,8 +52,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="16dp" - android:paddingRight="16dp" - android:paddingTop="16dp"> + android:paddingRight="16dp"> - + + + android:contentDescription="@string/action_mention" + app:srcCompat="@drawable/ic_create_24dp" /> From 099d76d9197b01f85ef557fc8ce0bbae8696c583 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Fri, 4 Aug 2017 11:44:10 +0200 Subject: [PATCH 3/7] make FAB hide on scroll in AccountActivity as well --- .../keylesspalace/tusky/AccountActivity.java | 24 +++++++- .../com/keylesspalace/tusky/MainActivity.java | 13 ++++- .../tusky/fragment/AccountListFragment.java | 57 +++++++++++++++++-- .../tusky/fragment/NotificationsFragment.java | 18 +++--- .../tusky/fragment/TimelineFragment.java | 33 +++++------ .../interfaces/ActionButtonActivity.java | 24 ++++++++ 6 files changed, 136 insertions(+), 33 deletions(-) create mode 100644 app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index 53d723b8..c0287e04 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -47,6 +47,7 @@ import android.widget.TextView; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Relationship; +import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.interfaces.LinkListener; import com.keylesspalace.tusky.pager.AccountPagerAdapter; import com.keylesspalace.tusky.receiver.TimelineReceiver; @@ -64,7 +65,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; -public class AccountActivity extends BaseActivity { +public class AccountActivity extends BaseActivity implements ActionButtonActivity { private static final String TAG = "AccountActivity"; // logging tag private enum FollowState { @@ -86,6 +87,8 @@ public class AccountActivity extends BaseActivity { private TabLayout tabLayout; private ImageView accountLockedView; private View container; + private boolean hideFab; + private int oldOffset; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -127,6 +130,8 @@ public class AccountActivity extends BaseActivity { actionBar.setDisplayShowHomeEnabled(true); } + hideFab = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fabHide", false); + // Add a listener to change the toolbar icon color when it enters/exits its collapsed state. AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.account_app_bar_layout); final CollapsingToolbarLayout collapsingToolbar = @@ -158,6 +163,16 @@ public class AccountActivity extends BaseActivity { ThemeUtils.setDrawableTint(context, toolbar.getNavigationIcon(), attribute); ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute); } + + if(floatingBtn != null && hideFab) { + if (verticalOffset > oldOffset) { + floatingBtn.show(); + } + if (verticalOffset < oldOffset) { + floatingBtn.hide(); + } + } + oldOffset = verticalOffset; } }); @@ -642,4 +657,11 @@ public class AccountActivity extends BaseActivity { } return super.onOptionsItemSelected(item); } + + @Nullable + @Override + public FloatingActionButton getActionButton() { + return floatingBtn; + } + } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 1e034837..7a3a64d5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -23,6 +23,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.PersistableBundle; +import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; import android.support.graphics.drawable.VectorDrawableCompat; @@ -37,6 +38,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import com.keylesspalace.tusky.entity.Account; +import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.pager.TimelinePagerAdapter; import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.util.ThemeUtils; @@ -63,7 +65,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; -public class MainActivity extends BaseActivity { +public class MainActivity extends BaseActivity implements ActionButtonActivity { private static final String TAG = "MainActivity"; // logging tag private static final long DRAWER_ITEM_EDIT_PROFILE = 0; private static final long DRAWER_ITEM_FAVOURITES = 1; @@ -77,7 +79,8 @@ public class MainActivity extends BaseActivity { private static final long DRAWER_ITEM_SAVED_TOOT = 9; protected static int COMPOSE_RESULT = 1; - public FloatingActionButton composeButton; + + private FloatingActionButton composeButton; private String loggedInAccountId; private String loggedInAccountUsername; private Stack pageHistory; @@ -493,4 +496,10 @@ public class MainActivity extends BaseActivity { private void onFetchUserInfoFailure(Exception exception) { Log.e(TAG, "Failed to fetch user info. " + exception.getMessage()); } + + @Nullable + @Override + public FloatingActionButton getActionButton() { + return composeButton; + } } \ No newline at end of file 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 e37cbd57..996c4206 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/AccountListFragment.java @@ -17,9 +17,12 @@ package com.keylesspalace.tusky.fragment; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.design.widget.TabLayout; import android.support.v7.widget.DividerItemDecoration; @@ -42,6 +45,7 @@ import com.keylesspalace.tusky.BaseActivity; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.interfaces.AccountActionListener; +import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.util.HttpHeaderLink; @@ -77,6 +81,7 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi private int bottomFetches; private boolean topLoading; private int topFetches; + private boolean hideFab; public static AccountListFragment newInstance(Type type) { Bundle arguments = new Bundle(); @@ -168,15 +173,55 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi * activity is created, so everything needing to access the api object has to be delayed * until here. */ api = activity.mastodonApi; - scrollListener = new EndlessOnScrollListener(layoutManager) { - @Override - public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { - AccountListFragment.this.onLoadMore(view); - } - }; + + + 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()); + hideFab = preferences.getBoolean("fabHide", false); + scrollListener = new EndlessOnScrollListener(layoutManager) { + @Override + public void onScrolled(RecyclerView view, int dx, int dy) { + super.onScrolled(view, dx, dy); + + if (composeButton != null) { + if (hideFab) { + if (dy > 0 && composeButton.isShown()) { + composeButton.hide(); // hides the button if we're scrolling down + } else if (dy < 0 && !composeButton.isShown()) { + composeButton.show(); // shows it if we are scrolling up + } + } else if (!composeButton.isShown()) { + composeButton.show(); + } + } + } + + @Override + public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { + AccountListFragment.this.onLoadMore(view); + } + }; + } else { + // Just use the basic scroll listener to load more accounts. + scrollListener = new EndlessOnScrollListener(layoutManager) { + @Override + public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { + AccountListFragment.this.onLoadMore(view); + } + }; + } + recyclerView.addOnScrollListener(scrollListener); } + private boolean actionButtonPresent() { + return type == Type.FOLLOWS || type == Type.FOLLOWERS; + } + @Override public void onDestroyView() { if (jumpToTopAllowed()) { 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 91f20654..8375bf86 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -172,7 +172,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.composeButton; + final FloatingActionButton composeButton = activity.getActionButton(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences( activity); preferences.registerOnSharedPreferenceChangeListener(this); @@ -182,14 +182,16 @@ public class NotificationsFragment extends SFragment implements public void onScrolled(RecyclerView view, int dx, int dy) { super.onScrolled(view, dx, dy); - if (hideFab) { - if (dy > 0 && composeButton.isShown()) { - composeButton.hide(); // hides the button if we're scrolling down - } else if (dy < 0 && !composeButton.isShown()) { - composeButton.show(); // shows it if we are scrolling up + if(composeButton != null) { + if (hideFab) { + if (dy > 0 && composeButton.isShown()) { + composeButton.hide(); // hides the button if we're scrolling down + } else if (dy < 0 && !composeButton.isShown()) { + composeButton.show(); // shows it if we are scrolling up + } + } else if (!composeButton.isShown()) { + composeButton.show(); } - } else if (!composeButton.isShown()) { - composeButton.show(); } } 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 0141dd37..379b9c42 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -34,11 +34,11 @@ import android.view.View; import android.view.ViewGroup; import com.keylesspalace.tusky.BuildConfig; -import com.keylesspalace.tusky.MainActivity; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.adapter.FooterViewHolder; import com.keylesspalace.tusky.adapter.TimelineAdapter; import com.keylesspalace.tusky.entity.Status; +import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.interfaces.StatusActionListener; import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.receiver.TimelineReceiver; @@ -195,28 +195,29 @@ public class TimelineFragment extends SFragment implements /* This is delayed until onActivityCreated solely because MainActivity.composeButton isn't * guaranteed to be set until then. */ - if (composeButtonPresent()) { + if (actionButtonPresent()) { /* Use a modified scroll listener that both loads more statuses as it goes, and hides * the follow button on down-scroll. */ - MainActivity activity = (MainActivity) getActivity(); - final FloatingActionButton composeButton = activity.composeButton; - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences( - activity); + ActionButtonActivity activity = (ActionButtonActivity) getActivity(); + final FloatingActionButton composeButton = activity.getActionButton(); + final 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); - if (hideFab) { - if (dy > 0 && composeButton.isShown()) { - composeButton.hide(); // hides the button if we're scrolling down - } else if (dy < 0 && !composeButton.isShown()) { - composeButton.show(); // shows it if we are scrolling up + if (composeButton != null) { + if (hideFab) { + if (dy > 0 && composeButton.isShown()) { + composeButton.hide(); // hides the button if we're scrolling down + } else if (dy < 0 && !composeButton.isShown()) { + composeButton.show(); // shows it if we are scrolling up + } + } else if (!composeButton.isShown()) { + composeButton.show(); } - } else if (!composeButton.isShown()) { - composeButton.show(); - } + } } @Override @@ -438,8 +439,8 @@ public class TimelineFragment extends SFragment implements return kind != Kind.TAG && kind != Kind.FAVOURITES; } - private boolean composeButtonPresent() { - return kind != Kind.TAG && kind != Kind.FAVOURITES && kind != Kind.USER; + private boolean actionButtonPresent() { + return kind != Kind.TAG && kind != Kind.FAVOURITES; } private void jumpToTop() { diff --git a/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java b/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java new file mode 100644 index 00000000..35d2b9c0 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/interfaces/ActionButtonActivity.java @@ -0,0 +1,24 @@ +/* Copyright 2017 Andrew Dawson + * + * This file is a part of Tusky. + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Tusky; if not, + * see . */ + +package com.keylesspalace.tusky.interfaces; + +import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; + +public interface ActionButtonActivity { + @Nullable + FloatingActionButton getActionButton(); +} From 848189d6700693cde19daae8fe11a92652b2616b Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sat, 5 Aug 2017 10:09:17 +0200 Subject: [PATCH 4/7] show if an account follows you back in AccountActivity --- .../keylesspalace/tusky/AccountActivity.java | 23 ++++++++++++------- app/src/main/res/layout/activity_account.xml | 22 ++++++++++++++---- app/src/main/res/values-de/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index c0287e04..3c2fec8b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -84,6 +84,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit private ImageView header; private FloatingActionButton floatingBtn; private Button followBtn; + private TextView followsYouView; private TabLayout tabLayout; private ImageView accountLockedView; private View container; @@ -99,6 +100,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit header = (ImageView) findViewById(R.id.account_header); floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); followBtn = (Button) findViewById(R.id.follow_btn); + followsYouView = (TextView) findViewById(R.id.account_follows_you); tabLayout = (TabLayout) findViewById(R.id.tab_layout); accountLockedView = (ImageView) findViewById(R.id.account_locked); container = findViewById(R.id.activity_account); @@ -179,6 +181,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit // Initialise the default UI states. floatingBtn.hide(); followBtn.setVisibility(View.GONE); + followsYouView.setVisibility(View.GONE); // Obtain information to fill out the profile. obtainAccount(); @@ -340,8 +343,7 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit Response> response) { if (response.isSuccessful()) { Relationship relationship = response.body().get(0); - onObtainRelationshipsSuccess(relationship.requested, relationship.following, - relationship.blocking, relationship.muting); + onObtainRelationshipsSuccess(relationship); } else { onObtainRelationshipsFailure(new Exception(response.message())); } @@ -354,22 +356,27 @@ public class AccountActivity extends BaseActivity implements ActionButtonActivit }); } - private void onObtainRelationshipsSuccess(boolean followRequested, boolean following, - boolean blocking, boolean muting) { - if (following) { + private void onObtainRelationshipsSuccess(Relationship relation) { + if (relation.following) { followState = FollowState.FOLLOWING; - } else if (followRequested) { + } else if (relation.requested) { followState = FollowState.REQUESTED; } else { followState = FollowState.NOT_FOLLOWING; } - this.blocking = blocking; - this.muting = muting; + this.blocking = relation.blocking; + this.muting = relation.muting; if (followState != FollowState.NOT_FOLLOWING || !blocking || !muting) { invalidateOptionsMenu(); } + if(relation.followedBy) { + followsYouView.setVisibility(View.VISIBLE); + } else { + followsYouView.setVisibility(View.GONE); + } + updateButtons(); } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index ca81039a..e0197e9d 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -58,22 +58,34 @@ 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:src="@drawable/avatar_default" - android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/follow_btn" android:layout_toStartOf="@+id/follow_btn" + android:src="@drawable/avatar_default" app:shadow="true" />