diff --git a/app/build.gradle b/app/build.gradle
index ec1a6174..6de288cc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -30,5 +30,7 @@ dependencies {
compile 'com.android.support:support-v13:25.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:25.1.0'
+ compile 'com.squareup.picasso:picasso:2.5.2'
+ compile 'com.pkmmte.view:circularimageview:1.1'
testCompile 'junit:junit:4.12'
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java
index dcb1f81a..dc81abfa 100644
--- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java
@@ -19,9 +19,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
+import android.icu.text.NumberFormat;
+import android.media.Image;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.support.design.widget.CollapsingToolbarLayout;
+import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
@@ -31,6 +35,7 @@ import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
import com.android.volley.AuthFailureError;
@@ -41,6 +46,8 @@ import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.NetworkImageView;
+import com.pkmmte.view.CircularImageView;
+import com.squareup.picasso.Picasso;
import org.json.JSONArray;
import org.json.JSONException;
@@ -78,11 +85,21 @@ public class AccountActivity extends BaseActivity {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
- NetworkImageView avatar = (NetworkImageView) findViewById(R.id.account_avatar);
- NetworkImageView header = (NetworkImageView) findViewById(R.id.account_header);
- avatar.setDefaultImageResId(R.drawable.avatar_default);
- avatar.setErrorImageResId(R.drawable.avatar_error);
- header.setDefaultImageResId(R.drawable.account_header_default);
+ ActionBar actionBar = getSupportActionBar();
+
+ if (actionBar != null) {
+ actionBar.setTitle(null);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setDisplayShowHomeEnabled(true);
+ }
+
+ FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn);
+ floatingBtn.hide();
+
+ CircularImageView avatar = (CircularImageView) findViewById(R.id.account_avatar);
+ ImageView header = (ImageView) findViewById(R.id.account_header);
+ avatar.setImageResource(R.drawable.avatar_default);
+ header.setImageResource(R.drawable.account_header_default);
obtainAccount();
if (!accountId.equals(loggedInAccountId)) {
@@ -165,39 +182,43 @@ public class AccountActivity extends BaseActivity {
TextView username = (TextView) findViewById(R.id.account_username);
TextView displayName = (TextView) findViewById(R.id.account_display_name);
TextView note = (TextView) findViewById(R.id.account_note);
- NetworkImageView avatar = (NetworkImageView) findViewById(R.id.account_avatar);
- NetworkImageView header = (NetworkImageView) findViewById(R.id.account_header);
+ CircularImageView avatar = (CircularImageView) findViewById(R.id.account_avatar);
+ ImageView header = (ImageView) findViewById(R.id.account_header);
String usernameFormatted = String.format(
getString(R.string.status_username_format), account.username);
username.setText(usernameFormatted);
displayName.setText(account.displayName);
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setTitle(account.displayName);
- }
note.setText(account.note);
note.setLinksClickable(true);
note.setMovementMethod(LinkMovementMethod.getInstance());
- ImageLoader imageLoader = VolleySingleton.getInstance(this).getImageLoader();
if (!account.avatar.isEmpty()) {
- avatar.setImageUrl(account.avatar, imageLoader);
+ Picasso.with(this)
+ .load(account.avatar)
+ .placeholder(R.drawable.avatar_default)
+ .error(R.drawable.avatar_error)
+ .into(avatar);
}
if (!account.header.isEmpty()) {
- header.setImageUrl(account.header, imageLoader);
+ Picasso.with(this)
+ .load(account.header)
+ .placeholder(R.drawable.account_header_default)
+ .into(header);
}
openInWebUrl = account.url;
+ java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
// Add counts to the tabs in the TabLayout.
String[] counts = {
- account.statusesCount,
- account.followingCount,
- account.followersCount,
+ nf.format(Integer.parseInt(account.statusesCount)),
+ nf.format(Integer.parseInt(account.followingCount)),
+ nf.format(Integer.parseInt(account.followersCount)),
};
+
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
if (tab != null) {
@@ -261,9 +282,37 @@ public class AccountActivity extends BaseActivity {
private void onObtainRelationshipsSuccess(boolean following, boolean blocking) {
this.following = following;
this.blocking = blocking;
+
if (!following || !blocking) {
invalidateOptionsMenu();
}
+
+ updateButtons();
+ }
+
+ private void updateButtons() {
+ invalidateOptionsMenu();
+
+ FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn);
+
+ if(!isSelf && !blocking) {
+ floatingBtn.show();
+
+ if (!following) {
+ floatingBtn.setImageResource(R.drawable.ic_person_add_24dp);
+ } else {
+ floatingBtn.setImageResource(R.drawable.ic_person_outline_24dp);
+ }
+
+ floatingBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ follow(accountId);
+ }
+ });
+ } else if(!isSelf && blocking) {
+ // TODO: floating button becomes unblock
+ }
}
private void onObtainRelationshipsFailure(Exception exception) {
@@ -337,7 +386,7 @@ public class AccountActivity extends BaseActivity {
return;
}
following = followingValue;
- invalidateOptionsMenu();
+ updateButtons();
}
},
new Response.ErrorListener() {
@@ -385,7 +434,7 @@ public class AccountActivity extends BaseActivity {
return;
}
blocking = blockingValue;
- invalidateOptionsMenu();
+ updateButtons();
}
},
new Response.ErrorListener() {
@@ -417,10 +466,8 @@ public class AccountActivity extends BaseActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_back: {
- Intent intent = new Intent(this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
+ case android.R.id.home: {
+ onBackPressed();
return true;
}
case R.id.action_open_in_web: {
diff --git a/app/src/main/res/drawable/account_header_gradient.xml b/app/src/main/res/drawable/account_header_gradient.xml
new file mode 100644
index 00000000..f1ae0bab
--- /dev/null
+++ b/app/src/main/res/drawable/account_header_gradient.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_person_add_24dp.xml b/app/src/main/res/drawable/ic_person_add_24dp.xml
new file mode 100644
index 00000000..5c029e12
--- /dev/null
+++ b/app/src/main/res/drawable/ic_person_add_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_person_outline_24dp.xml b/app/src/main/res/drawable/ic_person_outline_24dp.xml
new file mode 100644
index 00000000..4ad4f8d0
--- /dev/null
+++ b/app/src/main/res/drawable/ic_person_outline_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml
index e99535c8..42b67ff8 100644
--- a/app/src/main/res/layout/activity_account.xml
+++ b/app/src/main/res/layout/activity_account.xml
@@ -10,77 +10,93 @@
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+ android:id="@+id/account_note"
+ android:padding="16dp"
+ android:paddingTop="10dp"/>
+
+
@@ -119,4 +135,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/account_toolbar.xml b/app/src/main/res/menu/account_toolbar.xml
index bfc755c7..3188882e 100644
--- a/app/src/main/res/menu/account_toolbar.xml
+++ b/app/src/main/res/menu/account_toolbar.xml
@@ -2,11 +2,6 @@