Updates layouts and drawer actions
This commit is contained in:
parent
6a7f39b7a6
commit
13e1a97829
|
@ -48,6 +48,34 @@ public class Account implements Parcelable {
|
||||||
private String instance;
|
private String instance;
|
||||||
private boolean isFollowing;
|
private boolean isFollowing;
|
||||||
private boolean isRemote;
|
private boolean isRemote;
|
||||||
|
private followAction followType = followAction.NOTHING;
|
||||||
|
private boolean isMakingAction = false;
|
||||||
|
|
||||||
|
public followAction getFollowType() {
|
||||||
|
return followType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFollowType(followAction followType) {
|
||||||
|
this.followType = followType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMakingAction() {
|
||||||
|
return isMakingAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMakingAction(boolean makingAction) {
|
||||||
|
isMakingAction = makingAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum followAction{
|
||||||
|
FOLLOW,
|
||||||
|
NOT_FOLLOW,
|
||||||
|
BLOCK,
|
||||||
|
MUTE,
|
||||||
|
REQUEST_SENT,
|
||||||
|
NOTHING
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Account(Parcel in) {
|
protected Account(Parcel in) {
|
||||||
id = in.readString();
|
id = in.readString();
|
||||||
|
|
|
@ -78,7 +78,15 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
||||||
this.targetedId = targetedId;
|
this.targetedId = targetedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum action{
|
||||||
|
FOLLOW,
|
||||||
|
UNFOLLOW,
|
||||||
|
UNBLOCK,
|
||||||
|
NOTHING,
|
||||||
|
UNMUTE
|
||||||
|
}
|
||||||
|
|
||||||
|
private API.StatusAction doAction;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
|
@ -126,9 +134,8 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
||||||
holder.account_sc = (TextView) convertView.findViewById(R.id.account_sc);
|
holder.account_sc = (TextView) convertView.findViewById(R.id.account_sc);
|
||||||
holder.account_fgc = (TextView) convertView.findViewById(R.id.account_fgc);
|
holder.account_fgc = (TextView) convertView.findViewById(R.id.account_fgc);
|
||||||
holder.account_frc = (TextView) convertView.findViewById(R.id.account_frc);
|
holder.account_frc = (TextView) convertView.findViewById(R.id.account_frc);
|
||||||
holder.account_action_block = (FloatingActionButton) convertView.findViewById(R.id.account_action_block);
|
holder.account_follow = (FloatingActionButton) convertView.findViewById(R.id.account_follow);
|
||||||
holder.account_action_mute = (FloatingActionButton) convertView.findViewById(R.id.account_action_mute);
|
holder.account_follow_request = (TextView) convertView.findViewById(R.id.account_follow_request);
|
||||||
|
|
||||||
holder.account_container = (LinearLayout) convertView.findViewById(R.id.account_container);
|
holder.account_container = (LinearLayout) convertView.findViewById(R.id.account_container);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -136,24 +143,40 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
||||||
}
|
}
|
||||||
|
|
||||||
if( action == RetrieveAccountsAsyncTask.Type.BLOCKED)
|
if( action == RetrieveAccountsAsyncTask.Type.BLOCKED)
|
||||||
holder.account_action_block.setVisibility(View.VISIBLE);
|
account.setFollowType(Account.followAction.BLOCK);
|
||||||
else if( action == RetrieveAccountsAsyncTask.Type.MUTED)
|
else if( action == RetrieveAccountsAsyncTask.Type.MUTED)
|
||||||
holder.account_action_mute.setVisibility(View.VISIBLE);
|
account.setFollowType(Account.followAction.MUTE);
|
||||||
|
|
||||||
|
if (account.getFollowType() == Account.followAction.NOTHING){
|
||||||
|
holder.account_follow.setVisibility(View.GONE);
|
||||||
|
holder.account_follow_request.setVisibility(View.GONE);
|
||||||
|
doAction = null;
|
||||||
|
}else if( account.getFollowType() == Account.followAction.REQUEST_SENT){
|
||||||
|
holder.account_follow.setVisibility(View.GONE);
|
||||||
|
holder.account_follow_request.setVisibility(View.VISIBLE);
|
||||||
|
doAction = null;
|
||||||
|
}else if( account.getFollowType() == Account.followAction.FOLLOW){
|
||||||
|
holder.account_follow.setImageResource(R.drawable.ic_user_times);
|
||||||
|
doAction = API.StatusAction.UNFOLLOW;
|
||||||
|
holder.account_follow.setVisibility(View.VISIBLE);
|
||||||
|
holder.account_follow_request.setVisibility(View.GONE);
|
||||||
|
}else if( account.getFollowType() == Account.followAction.NOT_FOLLOW){
|
||||||
|
holder.account_follow.setImageResource(R.drawable.ic_user_plus);
|
||||||
|
doAction = API.StatusAction.FOLLOW;
|
||||||
|
holder.account_follow.setVisibility(View.VISIBLE);
|
||||||
|
holder.account_follow_request.setVisibility(View.GONE);
|
||||||
|
}else if( account.getFollowType() == Account.followAction.BLOCK){
|
||||||
|
holder.account_follow.setImageResource(R.drawable.ic_unlock_alt);
|
||||||
|
doAction = API.StatusAction.UNBLOCK;
|
||||||
|
holder.account_follow.setVisibility(View.VISIBLE);
|
||||||
|
holder.account_follow_request.setVisibility(View.GONE);
|
||||||
|
}else if( account.getFollowType() == Account.followAction.MUTE){
|
||||||
|
holder.account_follow.setImageResource(R.drawable.ic_unlock_alt);
|
||||||
|
doAction = API.StatusAction.UNMUTE;
|
||||||
|
holder.account_follow.setVisibility(View.VISIBLE);
|
||||||
|
holder.account_follow_request.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
holder.account_action_mute.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
moreOptionDialog(account);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.account_action_block.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
moreOptionDialog(account);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
holder.account_container.setOnClickListener(new View.OnClickListener() {
|
holder.account_container.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -184,6 +207,22 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
||||||
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if( account.isMakingAction()){
|
||||||
|
holder.account_follow.setEnabled(false);
|
||||||
|
}else {
|
||||||
|
holder.account_follow.setEnabled(true);
|
||||||
|
}
|
||||||
|
//Follow button
|
||||||
|
holder.account_follow.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if( doAction != null) {
|
||||||
|
account.setMakingAction(true);
|
||||||
|
new PostActionAsyncTask(context, doAction, account.getId(), AccountsListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
holder.account_pp.setOnClickListener(new View.OnClickListener() {
|
holder.account_pp.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -233,44 +272,9 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
|
||||||
TextView account_sc;
|
TextView account_sc;
|
||||||
TextView account_fgc;
|
TextView account_fgc;
|
||||||
TextView account_frc;
|
TextView account_frc;
|
||||||
|
FloatingActionButton account_follow;
|
||||||
|
TextView account_follow_request;
|
||||||
LinearLayout account_container;
|
LinearLayout account_container;
|
||||||
FloatingActionButton account_action_block;
|
|
||||||
FloatingActionButton account_action_mute;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* More option for acccounts (unmute / unblock)
|
|
||||||
* @param account Account current account
|
|
||||||
*/
|
|
||||||
private void moreOptionDialog(final Account account){
|
|
||||||
|
|
||||||
String[] stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm_account);
|
|
||||||
final API.StatusAction doAction;
|
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
|
|
||||||
|
|
||||||
if( action == RetrieveAccountsAsyncTask.Type.BLOCKED) {
|
|
||||||
dialog.setMessage(stringArrayConf[1]);
|
|
||||||
doAction = API.StatusAction.UNBLOCK;
|
|
||||||
}else {
|
|
||||||
dialog.setMessage(stringArrayConf[0]);
|
|
||||||
doAction = API.StatusAction.UNMUTE;
|
|
||||||
}
|
|
||||||
dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog,int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog,int which) {
|
|
||||||
new PostActionAsyncTask(context, doAction, account.getId(), AccountsListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -176,27 +176,5 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
/>
|
/>
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:id="@+id/account_action_block"
|
|
||||||
app:fabSize="mini"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:src="@drawable/ic_block_white" />
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:id="@+id/account_action_mute"
|
|
||||||
app:fabSize="mini"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:src="@drawable/ic_mute_white" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
Loading…
Reference in New Issue