chore: make the mute confirmation dialog work
TODO: Readd the time option
This commit is contained in:
@@ -11,10 +11,11 @@ import androidx.annotation.NonNull;
|
|||||||
public class MuteAccountConfirmationSheet extends AccountRestrictionConfirmationSheet{
|
public class MuteAccountConfirmationSheet extends AccountRestrictionConfirmationSheet{
|
||||||
public MuteAccountConfirmationSheet(@NonNull Context context, Account user, ConfirmCallback confirmCallback){
|
public MuteAccountConfirmationSheet(@NonNull Context context, Account user, ConfirmCallback confirmCallback){
|
||||||
super(context, user, confirmCallback);
|
super(context, user, confirmCallback);
|
||||||
|
//TODO: readd the time option
|
||||||
titleView.setText(R.string.mute_user_confirm_title);
|
titleView.setText(R.string.mute_user_confirm_title);
|
||||||
confirmBtn.setText(R.string.do_mute);
|
confirmBtn.setText(R.string.do_mute);
|
||||||
secondaryBtn.setVisibility(View.GONE);
|
secondaryBtn.setVisibility(View.GONE);
|
||||||
icon.setImageResource(R.drawable.ic_fluent_speaker_mute_24_regular);
|
icon.setImageResource(R.drawable.ic_fluent_speaker_off_24_regular);
|
||||||
subtitleView.setText(user.getDisplayUsername());
|
subtitleView.setText(user.getDisplayUsername());
|
||||||
addRow(R.drawable.ic_campaign_24px, R.string.user_wont_know_muted);
|
addRow(R.drawable.ic_campaign_24px, R.string.user_wont_know_muted);
|
||||||
addRow(R.drawable.ic_fluent_eye_off_24_regular, R.string.user_can_still_see_your_posts);
|
addRow(R.drawable.ic_fluent_eye_off_24_regular, R.string.user_can_still_see_your_posts);
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ import org.joinmastodon.android.model.SearchResults;
|
|||||||
import org.joinmastodon.android.model.Searchable;
|
import org.joinmastodon.android.model.Searchable;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
||||||
|
import org.joinmastodon.android.ui.Snackbar;
|
||||||
|
import org.joinmastodon.android.ui.sheets.MuteAccountConfirmationSheet;
|
||||||
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
|
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
|
||||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
@@ -581,69 +583,109 @@ public class UiUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void confirmToggleMuteUser(Context context, String accountID, Account account, boolean currentlyMuted, Consumer<Relationship> resultCallback){
|
public static void confirmToggleMuteUser(Context context, String accountID, Account account, boolean currentlyMuted, Consumer<Relationship> resultCallback){
|
||||||
View durationView=LayoutInflater.from(context).inflate(R.layout.mute_user_dialog, null);
|
if(!currentlyMuted){
|
||||||
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
new MuteAccountConfirmationSheet(context, account, (onSuccess, onError)->{
|
||||||
params.setMargins(0, V.dp(-12), 0, 0);
|
new SetAccountMuted(account.id, true, 0)
|
||||||
durationView.setLayoutParams(params);
|
.setCallback(new Callback<>(){
|
||||||
Button button=durationView.findViewById(R.id.button);
|
@Override
|
||||||
((TextView) durationView.findViewById(R.id.message)).setText(context.getString(R.string.confirm_mute, account.getDisplayName()));
|
public void onSuccess(Relationship result){
|
||||||
|
resultCallback.accept(result);
|
||||||
|
onSuccess.run();
|
||||||
|
E.post(new RemoveAccountPostsEvent(accountID, account.id, false));
|
||||||
|
}
|
||||||
|
|
||||||
AtomicReference<Duration> muteDuration=new AtomicReference<>(Duration.ZERO);
|
@Override
|
||||||
|
public void onError(ErrorResponse error){
|
||||||
|
error.showToast(context);
|
||||||
|
onError.run();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec(accountID);
|
||||||
|
}).show();
|
||||||
|
}else{
|
||||||
|
new SetAccountMuted(account.id, false, 0)
|
||||||
|
.setCallback(new Callback<>(){
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Relationship result){
|
||||||
|
resultCallback.accept(result);
|
||||||
|
new Snackbar.Builder(context)
|
||||||
|
.setText(context.getString(R.string.unmuted_user_x, account.getDisplayUsername()))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
PopupMenu popupMenu=new PopupMenu(context, button, Gravity.CENTER_HORIZONTAL);
|
@Override
|
||||||
popupMenu.inflate(R.menu.mute_duration);
|
public void onError(ErrorResponse error){
|
||||||
popupMenu.setOnMenuItemClickListener(item->{
|
error.showToast(context);
|
||||||
int id=item.getItemId();
|
}
|
||||||
if(id==R.id.duration_indefinite)
|
})
|
||||||
muteDuration.set(Duration.ZERO);
|
.wrapProgress(context, R.string.loading, false)
|
||||||
else if(id==R.id.duration_minutes_5){
|
.exec(accountID);
|
||||||
muteDuration.set(Duration.ofMinutes(5));
|
}
|
||||||
}else if(id==R.id.duration_minutes_30){
|
|
||||||
muteDuration.set(Duration.ofMinutes(30));
|
|
||||||
}else if(id==R.id.duration_hours_1){
|
|
||||||
muteDuration.set(Duration.ofHours(1));
|
|
||||||
}else if(id==R.id.duration_hours_6){
|
|
||||||
muteDuration.set(Duration.ofHours(6));
|
|
||||||
}else if(id==R.id.duration_days_1){
|
|
||||||
muteDuration.set(Duration.ofDays(1));
|
|
||||||
}else if(id==R.id.duration_days_3){
|
|
||||||
muteDuration.set(Duration.ofDays(3));
|
|
||||||
}else if(id==R.id.duration_days_7){
|
|
||||||
muteDuration.set(Duration.ofDays(7));
|
|
||||||
}
|
|
||||||
button.setText(item.getTitle());
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
button.setOnTouchListener(popupMenu.getDragToOpenListener());
|
|
||||||
button.setOnClickListener(v->popupMenu.show());
|
|
||||||
button.setText(popupMenu.getMenu().getItem(0).getTitle());
|
|
||||||
|
|
||||||
new M3AlertDialogBuilder(context)
|
// I need to readd the mute thing, so this is gonna stay as a comment for now
|
||||||
.setTitle(context.getString(currentlyMuted ? R.string.confirm_unmute_title : R.string.confirm_mute_title))
|
// View durationView=LayoutInflater.from(context).inflate(R.layout.mute_user_dialog, null);
|
||||||
.setMessage(currentlyMuted ? context.getString(R.string.confirm_unmute, account.getDisplayName()) : null)
|
// LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
.setView(currentlyMuted ? null : durationView)
|
// params.setMargins(0, V.dp(-12), 0, 0);
|
||||||
.setPositiveButton(context.getString(currentlyMuted ? R.string.do_unmute : R.string.do_mute), (dlg, i)->{
|
// durationView.setLayoutParams(params);
|
||||||
new SetAccountMuted(account.id, !currentlyMuted, muteDuration.get().getSeconds())
|
// Button button=durationView.findViewById(R.id.button);
|
||||||
.setCallback(new Callback<>(){
|
// ((TextView) durationView.findViewById(R.id.message)).setText(context.getString(R.string.confirm_mute, account.getDisplayName()));
|
||||||
@Override
|
//
|
||||||
public void onSuccess(Relationship result){
|
// AtomicReference<Duration> muteDuration=new AtomicReference<>(Duration.ZERO);
|
||||||
resultCallback.accept(result);
|
//
|
||||||
if(!currentlyMuted){
|
// PopupMenu popupMenu=new PopupMenu(context, button, Gravity.CENTER_HORIZONTAL);
|
||||||
E.post(new RemoveAccountPostsEvent(accountID, account.id, false));
|
// popupMenu.inflate(R.menu.mute_duration);
|
||||||
}
|
// popupMenu.setOnMenuItemClickListener(item->{
|
||||||
}
|
// int id=item.getItemId();
|
||||||
|
// if(id==R.id.duration_indefinite)
|
||||||
@Override
|
// muteDuration.set(Duration.ZERO);
|
||||||
public void onError(ErrorResponse error){
|
// else if(id==R.id.duration_minutes_5){
|
||||||
error.showToast(context);
|
// muteDuration.set(Duration.ofMinutes(5));
|
||||||
}
|
// }else if(id==R.id.duration_minutes_30){
|
||||||
})
|
// muteDuration.set(Duration.ofMinutes(30));
|
||||||
.wrapProgress(context, R.string.loading, false)
|
// }else if(id==R.id.duration_hours_1){
|
||||||
.exec(accountID);
|
// muteDuration.set(Duration.ofHours(1));
|
||||||
})
|
// }else if(id==R.id.duration_hours_6){
|
||||||
.setNegativeButton(R.string.cancel, null)
|
// muteDuration.set(Duration.ofHours(6));
|
||||||
.setIcon(currentlyMuted ? R.drawable.ic_fluent_speaker_2_28_regular : R.drawable.ic_fluent_speaker_off_28_regular)
|
// }else if(id==R.id.duration_days_1){
|
||||||
.show();
|
// muteDuration.set(Duration.ofDays(1));
|
||||||
|
// }else if(id==R.id.duration_days_3){
|
||||||
|
// muteDuration.set(Duration.ofDays(3));
|
||||||
|
// }else if(id==R.id.duration_days_7){
|
||||||
|
// muteDuration.set(Duration.ofDays(7));
|
||||||
|
// }
|
||||||
|
// button.setText(item.getTitle());
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
// button.setOnTouchListener(popupMenu.getDragToOpenListener());
|
||||||
|
// button.setOnClickListener(v->popupMenu.show());
|
||||||
|
// button.setText(popupMenu.getMenu().getItem(0).getTitle());
|
||||||
|
//
|
||||||
|
// new M3AlertDialogBuilder(context)
|
||||||
|
// .setTitle(context.getString(currentlyMuted ? R.string.confirm_unmute_title : R.string.confirm_mute_title))
|
||||||
|
// .setMessage(currentlyMuted ? context.getString(R.string.confirm_unmute, account.getDisplayName()) : null)
|
||||||
|
// .setView(currentlyMuted ? null : durationView)
|
||||||
|
// .setPositiveButton(context.getString(currentlyMuted ? R.string.do_unmute : R.string.do_mute), (dlg, i)->{
|
||||||
|
// new SetAccountMuted(account.id, !currentlyMuted, muteDuration.get().getSeconds())
|
||||||
|
// .setCallback(new Callback<>(){
|
||||||
|
// @Override
|
||||||
|
// public void onSuccess(Relationship result){
|
||||||
|
// resultCallback.accept(result);
|
||||||
|
// if(!currentlyMuted){
|
||||||
|
// E.post(new RemoveAccountPostsEvent(accountID, account.id, false));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onError(ErrorResponse error){
|
||||||
|
// error.showToast(context);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .wrapProgress(context, R.string.loading, false)
|
||||||
|
// .exec(accountID);
|
||||||
|
// })
|
||||||
|
// .setNegativeButton(R.string.cancel, null)
|
||||||
|
// .setIcon(currentlyMuted ? R.drawable.ic_fluent_speaker_2_28_regular : R.drawable.ic_fluent_speaker_off_28_regular)
|
||||||
|
// .show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void confirmDeletePost(Activity activity, String accountID, Status status, Consumer<Status> resultCallback, boolean forRedraft) {
|
public static void confirmDeletePost(Activity activity, String accountID, Status status, Consumer<Status> resultCallback, boolean forRedraft) {
|
||||||
|
|||||||
Reference in New Issue
Block a user