Follow requests list is available. Closes #222
parent
a4b51430b4
commit
acaefff326
@ -0,0 +1,129 @@ |
||||
/* 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 <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky; |
||||
|
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.ImageButton; |
||||
import android.widget.TextView; |
||||
|
||||
import com.keylesspalace.tusky.entity.Account; |
||||
import com.pkmmte.view.CircularImageView; |
||||
import com.squareup.picasso.Picasso; |
||||
|
||||
import butterknife.BindView; |
||||
import butterknife.ButterKnife; |
||||
|
||||
class FollowRequestsAdapter extends AccountAdapter { |
||||
private static final int VIEW_TYPE_FOLLOW_REQUEST = 0; |
||||
private static final int VIEW_TYPE_FOOTER = 1; |
||||
|
||||
FollowRequestsAdapter(AccountActionListener accountActionListener) { |
||||
super(accountActionListener); |
||||
} |
||||
|
||||
@Override |
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
||||
switch (viewType) { |
||||
default: |
||||
case VIEW_TYPE_FOLLOW_REQUEST: { |
||||
View view = LayoutInflater.from(parent.getContext()) |
||||
.inflate(R.layout.item_follow_request, parent, false); |
||||
return new FollowRequestViewHolder(view); |
||||
} |
||||
case VIEW_TYPE_FOOTER: { |
||||
View view = LayoutInflater.from(parent.getContext()) |
||||
.inflate(R.layout.item_footer, parent, false); |
||||
return new FooterViewHolder(view); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { |
||||
if (position < accountList.size()) { |
||||
FollowRequestViewHolder holder = (FollowRequestViewHolder) viewHolder; |
||||
holder.setupWithAccount(accountList.get(position)); |
||||
holder.setupActionListener(accountActionListener); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int getItemViewType(int position) { |
||||
if (position == accountList.size()) { |
||||
return VIEW_TYPE_FOOTER; |
||||
} else { |
||||
return VIEW_TYPE_FOLLOW_REQUEST; |
||||
} |
||||
} |
||||
|
||||
static class FollowRequestViewHolder extends RecyclerView.ViewHolder { |
||||
@BindView(R.id.follow_request_avatar) CircularImageView avatar; |
||||
@BindView(R.id.follow_request_username) TextView username; |
||||
@BindView(R.id.follow_request_display_name) TextView displayName; |
||||
@BindView(R.id.follow_request_accept) ImageButton accept; |
||||
@BindView(R.id.follow_request_reject) ImageButton reject; |
||||
|
||||
private String id; |
||||
|
||||
FollowRequestViewHolder(View itemView) { |
||||
super(itemView); |
||||
ButterKnife.bind(this, itemView); |
||||
} |
||||
|
||||
void setupWithAccount(Account account) { |
||||
id = account.id; |
||||
displayName.setText(account.getDisplayName()); |
||||
String format = username.getContext().getString(R.string.status_username_format); |
||||
String formattedUsername = String.format(format, account.username); |
||||
username.setText(formattedUsername); |
||||
Picasso.with(avatar.getContext()) |
||||
.load(account.avatar) |
||||
.error(R.drawable.avatar_error) |
||||
.placeholder(R.drawable.avatar_default) |
||||
.into(avatar); |
||||
} |
||||
|
||||
void setupActionListener(final AccountActionListener listener) { |
||||
accept.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
int position = getAdapterPosition(); |
||||
if (position != RecyclerView.NO_POSITION) { |
||||
listener.onRespondToFollowRequest(true, id, position); |
||||
} |
||||
} |
||||
}); |
||||
reject.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
int position = getAdapterPosition(); |
||||
if (position != RecyclerView.NO_POSITION) { |
||||
listener.onRespondToFollowRequest(false, id, position); |
||||
} |
||||
} |
||||
}); |
||||
avatar.setOnClickListener(new View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
listener.onViewAccount(id); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
@ -1,7 +1,9 @@ |
||||
<vector android:height="24dp" android:viewportHeight="35.43307" |
||||
android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<path android:fillAlpha="1" android:fillColor="#ffffff" |
||||
android:pathData="M32.16,4.46L31.62,5.01L14.63,21.99L5.78,13.13L2.5,16.41L14.52,28.43L14.55,28.41L14.66,28.52L35.44,7.74L34.89,7.19C34.17,6.46 33.44,5.74 32.71,5.01L32.16,4.46z" /> |
||||
<path android:fillAlpha="1" android:fillColor="#ffffff" |
||||
android:pathData="m1.1,6.19c-0.58,0 -1.07,0.49 -1.07,1.07l0,23.06c0,0.58 0.49,1.07 1.07,1.07l23.06,0c0.58,0 1.07,-0.49 1.07,-1.07l0,-18.89 -1.54,1.54 0,16.88 -22.12,0 0,-22.12 22.12,0 0,2.83 1.54,-1.54 0,-1.76c0,-0.58 -0.49,-1.07 -1.07,-1.07l-23.06,0z" /> |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24.0" |
||||
android:viewportHeight="24.0"> |
||||
<path |
||||
android:fillColor="#FFFFFFFF" |
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> |
||||
</vector> |
||||
|
@ -0,0 +1,7 @@ |
||||
<vector android:height="24dp" android:viewportHeight="35.43307" |
||||
android:viewportWidth="35.43307" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<path android:fillAlpha="1" android:fillColor="#ffffff" |
||||
android:pathData="M32.16,4.46L31.62,5.01L14.63,21.99L5.78,13.13L2.5,16.41L14.52,28.43L14.55,28.41L14.66,28.52L35.44,7.74L34.89,7.19C34.17,6.46 33.44,5.74 32.71,5.01L32.16,4.46z" /> |
||||
<path android:fillAlpha="1" android:fillColor="#ffffff" |
||||
android:pathData="m1.1,6.19c-0.58,0 -1.07,0.49 -1.07,1.07l0,23.06c0,0.58 0.49,1.07 1.07,1.07l23.06,0c0.58,0 1.07,-0.49 1.07,-1.07l0,-18.89 -1.54,1.54 0,16.88 -22.12,0 0,-22.12 22.12,0 0,2.83 1.54,-1.54 0,-1.76c0,-0.58 -0.49,-1.07 -1.07,-1.07l-23.06,0z" /> |
||||
</vector> |
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24.0" |
||||
android:viewportHeight="24.0"> |
||||
<path |
||||
android:fillColor="#FFFFFFFF" |
||||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> |
||||
</vector> |
@ -0,0 +1,80 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="72dp" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:paddingLeft="16dp" |
||||
android:paddingRight="16dp" |
||||
android:gravity="center_vertical"> |
||||
|
||||
<com.pkmmte.view.CircularImageView |
||||
android:layout_width="48dp" |
||||
android:layout_height="48dp" |
||||
android:id="@+id/follow_request_avatar" |
||||
android:layout_alignParentLeft="true" |
||||
android:layout_alignParentStart="true" |
||||
android:layout_marginRight="24dp" |
||||
android:layout_marginEnd="24dp" |
||||
android:layout_centerVertical="true" |
||||
android:contentDescription="@string/action_view_profile" /> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:gravity="center_vertical" |
||||
android:orientation="vertical" |
||||
android:layout_toRightOf="@id/follow_request_avatar" |
||||
android:layout_toEndOf="@id/follow_request_avatar" |
||||
android:layout_toLeftOf="@+id/follow_request_accept" |
||||
android:layout_toStartOf="@id/follow_request_accept"> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:id="@+id/follow_request_display_name" |
||||
android:text="Display name" |
||||
android:maxLines="1" |
||||
android:ellipsize="end" |
||||
android:textSize="16sp" |
||||
android:textColor="?android:textColorPrimary" |
||||
android:textStyle="normal|bold" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:text="\@username" |
||||
android:maxLines="1" |
||||
android:ellipsize="end" |
||||
android:textSize="14sp" |
||||
android:id="@+id/follow_request_username" |
||||
android:textColor="?android:textColorSecondary" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<ImageButton |
||||
android:layout_width="24dp" |
||||
android:layout_height="24dp" |
||||
style="?attr/image_button_style" |
||||
android:id="@+id/follow_request_accept" |
||||
app:srcCompat="@drawable/ic_check_24dp" |
||||
android:layout_toLeftOf="@+id/follow_request_reject" |
||||
android:layout_toStartOf="@id/follow_request_reject" |
||||
android:layout_marginLeft="16dp" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_centerVertical="true" |
||||
android:contentDescription="@string/action_accept" /> |
||||
|
||||
<ImageButton |
||||
android:layout_width="24dp" |
||||
android:layout_height="24dp" |
||||
style="?attr/image_button_style" |
||||
android:id="@id/follow_request_reject" |
||||
app:srcCompat="@drawable/ic_reject_24dp" |
||||
android:layout_alignParentRight="true" |
||||
android:layout_alignParentEnd="true" |
||||
android:layout_marginLeft="16dp" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_centerVertical="true" |
||||
android:contentDescription="@string/action_reject" /> |
||||
|
||||
</RelativeLayout> |
Loading…
Reference in new issue