Blocked domains - some fixes
This commit is contained in:
parent
045e5a80ed
commit
82432007e5
|
@ -1029,7 +1029,9 @@ public class API {
|
||||||
action = String.format("/accounts/%s/block", targetedId);
|
action = String.format("/accounts/%s/block", targetedId);
|
||||||
break;
|
break;
|
||||||
case BLOCK_DOMAIN:
|
case BLOCK_DOMAIN:
|
||||||
action = String.format("/domain_blocks/%s", targetedId);
|
action = "/domain_blocks";
|
||||||
|
params = new HashMap<>();
|
||||||
|
params.put("domain", targetedId);
|
||||||
break;
|
break;
|
||||||
case UNBLOCK:
|
case UNBLOCK:
|
||||||
action = String.format("/accounts/%s/unblock", targetedId);
|
action = String.format("/accounts/%s/unblock", targetedId);
|
||||||
|
|
|
@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.drawers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -26,13 +27,18 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.DeleteDomainsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.DeleteDomainsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveDomainsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveDomainsInterface;
|
||||||
|
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 26/09/2018.
|
* 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) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
final DomainsListAdapter.ViewHolder holder = (DomainsListAdapter.ViewHolder) viewHolder;
|
final DomainsListAdapter.ViewHolder holder = (DomainsListAdapter.ViewHolder) viewHolder;
|
||||||
final String domain = domains.get(position);
|
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_name.setText(domain);
|
||||||
holder.domain_delete.setOnClickListener(new View.OnClickListener() {
|
holder.domain_delete.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +129,13 @@ public class DomainsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRetrieveDomainsDeleted(int response) {
|
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{
|
private class ViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
|
@ -43,6 +43,7 @@ import android.text.Spannable;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
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_redraft).setVisible(false);
|
||||||
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
|
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
|
||||||
//Same instance
|
//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);
|
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);
|
||||||
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
|
stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm);
|
||||||
if( type != RetrieveFeedsAsyncTask.Type.HOME){
|
if( type != RetrieveFeedsAsyncTask.Type.HOME){
|
||||||
|
|
|
@ -727,6 +727,8 @@ public class Helper {
|
||||||
message = context.getString(R.string.toast_show_boost);
|
message = context.getString(R.string.toast_show_boost);
|
||||||
}else if(statusAction == API.StatusAction.HIDE_BOOST){
|
}else if(statusAction == API.StatusAction.HIDE_BOOST){
|
||||||
message = context.getString(R.string.toast_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 {
|
}else {
|
||||||
|
|
|
@ -629,6 +629,8 @@
|
||||||
<string name="block_domain_confirm_message">Are you sure to block %s?</string>
|
<string name="block_domain_confirm_message">Are you sure to block %s?</string>
|
||||||
<string name="blocked_domains">Blocked domains</string>
|
<string name="blocked_domains">Blocked domains</string>
|
||||||
<string name="block_domain">Block domain</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">
|
<string-array name="filter_expire">
|
||||||
<item>Never</item>
|
<item>Never</item>
|
||||||
|
|
Loading…
Reference in New Issue