From e4c9b229d707f22202952cf564de5ebddc8cbc14 Mon Sep 17 00:00:00 2001
From: Conny Duck <k.pozniak@gmx.at>
Date: Fri, 4 Aug 2017 10:53:38 +0200
Subject: [PATCH] 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<Relationship> cb = new Callback<Relationship>() {
             @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">
 
                         <com.pkmmte.view.CircularImageView
                             android:id="@+id/account_avatar"
@@ -62,16 +61,24 @@
                             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"
                             app:shadow="true" />
 
-                        <LinearLayout
+                        <Button
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:layout_alignParentEnd="true"
                             android:layout_alignParentRight="true"
-                            android:layout_centerVertical="true"
-                            android:layout_toEndOf="@id/account_avatar"
-                            android:layout_toRightOf="@id/account_avatar"
+                            android:layout_marginTop="6dp"
+                            android:id="@+id/follow_btn"/>
+
+                        <LinearLayout
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            android:layout_below="@id/account_avatar"
                             android:orientation="vertical">
 
                             <TextView
@@ -189,7 +196,7 @@
         android:layout_height="wrap_content"
         android:layout_gravity="bottom|end"
         android:layout_margin="16dp"
-        android:contentDescription="@string/action_follow"
-        app:srcCompat="@drawable/ic_person_add_24dp" />
+        android:contentDescription="@string/action_mention"
+        app:srcCompat="@drawable/ic_create_24dp" />
 
 </android.support.design.widget.CoordinatorLayout>