Blocked domains - some fixes

This commit is contained in:
stom79 2018-09-26 19:18:54 +02:00
parent 045e5a80ed
commit 82432007e5
5 changed files with 29 additions and 4 deletions

View File

@ -1029,7 +1029,9 @@ public class API {
action = String.format("/accounts/%s/block", targetedId);
break;
case BLOCK_DOMAIN:
action = String.format("/domain_blocks/%s", targetedId);
action = "/domain_blocks";
params = new HashMap<>();
params.put("domain", targetedId);
break;
case UNBLOCK:
action = String.format("/accounts/%s/unblock", targetedId);

View File

@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.drawers;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
@ -26,13 +27,18 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.List;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.DeleteDomainsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveDomainsInterface;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
/**
* Created by Thomas on 26/09/2018.
@ -65,7 +71,13 @@ public class DomainsListAdapter extends RecyclerView.Adapter implements OnRetrie
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
final DomainsListAdapter.ViewHolder holder = (DomainsListAdapter.ViewHolder) viewHolder;
final String domain = domains.get(position);
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_DARK){
changeDrawableColor(context, holder.domain_delete, R.color.dark_text);
}else{
changeDrawableColor(context, holder.domain_delete, R.color.black);
}
holder.domain_name.setText(domain);
holder.domain_delete.setOnClickListener(new View.OnClickListener() {
@Override
@ -117,7 +129,13 @@ public class DomainsListAdapter extends RecyclerView.Adapter implements OnRetrie
@Override
public void onRetrieveDomainsDeleted(int response) {
String message;
if( response == 200){
message = context.getString(R.string.toast_unblock_domain);
}else{
message = context.getString(R.string.toast_error);
}
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}
private class ViewHolder extends RecyclerView.ViewHolder{

View File

@ -43,6 +43,7 @@ import android.text.Spannable;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -1193,7 +1194,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
//Same instance
if(status.getAccount().getAcct().split("#").length <2 )
if(status.getAccount().getAcct().split("@").length <2 )
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
if( type != RetrieveFeedsAsyncTask.Type.HOME){

View File

@ -727,6 +727,8 @@ public class Helper {
message = context.getString(R.string.toast_show_boost);
}else if(statusAction == API.StatusAction.HIDE_BOOST){
message = context.getString(R.string.toast_hide_boost);
}else if(statusAction == API.StatusAction.BLOCK_DOMAIN){
message = context.getString(R.string.toast_block_domain);
}
}else {

View File

@ -629,6 +629,8 @@
<string name="block_domain_confirm_message">Are you sure to block %s?</string>
<string name="blocked_domains">Blocked domains</string>
<string name="block_domain">Block domain</string>
<string name="toast_block_domain">The domain is blocked</string>
<string name="toast_unblock_domain">The domain is no longer blocked!</string>
<string-array name="filter_expire">
<item>Never</item>