Adds the possibility to block/mute from the account page.
This commit is contained in:
parent
0837f30b8b
commit
1e8c2ded46
|
@ -15,6 +15,7 @@
|
|||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -39,6 +40,7 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.text.SpannableString;
|
||||
|
@ -124,6 +126,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
private CircleImageView account_pp;
|
||||
private TextView account_dn;
|
||||
private TextView account_un;
|
||||
private Account account;
|
||||
|
||||
public enum action{
|
||||
FOLLOW,
|
||||
|
@ -133,7 +136,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
}
|
||||
|
||||
private action doAction;
|
||||
|
||||
private API.StatusAction doActionAccount;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -283,14 +286,28 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
account_menu.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupMenu popup = new PopupMenu(ShowAccountActivity.this, account_menu);
|
||||
if( account == null)
|
||||
return;
|
||||
final PopupMenu popup = new PopupMenu(ShowAccountActivity.this, account_menu);
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.main_showaccount, popup.getMenu());
|
||||
if( !Helper.canPin || !accountId.equals(userId)) {
|
||||
popup.getMenu().findItem(R.id.action_show_pinned).setVisible(false);
|
||||
}
|
||||
final String[] stringArrayConf;
|
||||
final boolean isOwner = account.getId().equals(userId);
|
||||
if( isOwner) {
|
||||
popup.getMenu().findItem(R.id.action_block).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
|
||||
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);
|
||||
}else {
|
||||
popup.getMenu().findItem(R.id.action_block).setVisible(true);
|
||||
popup.getMenu().findItem(R.id.action_mute).setVisible(true);
|
||||
stringArrayConf = getResources().getStringArray(R.array.more_action_confirm);
|
||||
}
|
||||
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
AlertDialog.Builder builderInner;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_pinned:
|
||||
showPinned = !showPinned;
|
||||
|
@ -319,9 +336,34 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
case R.id.action_mute:
|
||||
builderInner = new AlertDialog.Builder(ShowAccountActivity.this);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
doActionAccount = API.StatusAction.MUTE;
|
||||
break;
|
||||
case R.id.action_block:
|
||||
builderInner = new AlertDialog.Builder(ShowAccountActivity.this);
|
||||
builderInner.setTitle(stringArrayConf[1]);
|
||||
doActionAccount = API.StatusAction.BLOCK;
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,int which) {
|
||||
new PostActionAsyncTask(getApplicationContext(), doActionAccount, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
|
@ -354,7 +396,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
this.account = account;
|
||||
accountUrl = account.getUrl();
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
|
|
|
@ -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="#FF000000"
|
||||
android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z"/>
|
||||
</vector>
|
|
@ -77,7 +77,8 @@
|
|||
android:layout_marginEnd="10dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="5dp"/>
|
||||
android:layout_marginTop="5dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</RelativeLayout>
|
||||
<LinearLayout
|
||||
android:layout_marginTop="60dp"
|
||||
|
|
|
@ -16,4 +16,14 @@
|
|||
android:title="@string/media"
|
||||
android:icon="@drawable/ic_perm_media"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_mute"
|
||||
android:title="@string/more_action_1"
|
||||
android:icon="@drawable/ic_mute_white"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_block"
|
||||
android:title="@string/more_action_2"
|
||||
android:icon="@drawable/ic_block_white"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
|
Loading…
Reference in New Issue