mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-24 01:30:04 +02:00
Fix issue #533 - Add an option to keep notifications when muting
This commit is contained in:
parent
b5a304be56
commit
0b690838bb
3 changed files with 61 additions and 43 deletions
|
@ -695,7 +695,6 @@ public class ProfileActivity extends BaseActivity {
|
||||||
splitAcct = account.acct.split("@");
|
splitAcct = account.acct.split("@");
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ProfileActivity.this);
|
||||||
AlertDialog.Builder builderInner = null;
|
|
||||||
final boolean isOwner = account != null && account.id != null && BaseMainActivity.currentUserID != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0;
|
final boolean isOwner = account != null && account.id != null && BaseMainActivity.currentUserID != null && account.id.compareToIgnoreCase(BaseMainActivity.currentUserID) == 0;
|
||||||
final String[] stringArrayConf;
|
final String[] stringArrayConf;
|
||||||
if (isOwner) {
|
if (isOwner) {
|
||||||
|
@ -920,21 +919,43 @@ public class ProfileActivity extends BaseActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_mute) {
|
} else if (itemId == R.id.action_mute) {
|
||||||
|
AlertDialog.Builder builderInner;
|
||||||
if (relationship != null) {
|
if (relationship != null) {
|
||||||
if (relationship.muting) {
|
String target;
|
||||||
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
if (item.getItemId() == R.id.action_block_instance) {
|
||||||
builderInner.setTitle(stringArrayConf[4]);
|
target = account.acct.split("@")[1];
|
||||||
doActionAccount = action.UNMUTE;
|
|
||||||
} else {
|
} else {
|
||||||
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
target = account.id;
|
||||||
builderInner.setTitle(stringArrayConf[0]);
|
|
||||||
doActionAccount = action.MUTE;
|
|
||||||
}
|
}
|
||||||
} else {
|
if (relationship.muting) {
|
||||||
doActionAccount = action.NOTHING;
|
accountsVM.unmute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target)
|
||||||
}
|
.observe(ProfileActivity.this, relationShip -> {
|
||||||
|
this.relationship = relationShip;
|
||||||
|
updateAccount();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
||||||
|
builderInner.setTitle(stringArrayConf[0]);
|
||||||
|
|
||||||
|
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||||
|
builderInner.setNegativeButton(R.string.keep_notifications, (dialog, which) -> {
|
||||||
|
accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target, false, 0)
|
||||||
|
.observe(ProfileActivity.this, relationShip -> {
|
||||||
|
this.relationship = relationShip;
|
||||||
|
updateAccount();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> {
|
||||||
|
accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target, true, 0)
|
||||||
|
.observe(ProfileActivity.this, relationShip -> {
|
||||||
|
this.relationship = relationShip;
|
||||||
|
updateAccount();
|
||||||
|
});
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
builderInner.show();
|
||||||
|
}
|
||||||
} else if (itemId == R.id.action_timed_mute) {
|
} else if (itemId == R.id.action_timed_mute) {
|
||||||
MastodonHelper.scheduleBoost(ProfileActivity.this, MastodonHelper.ScheduleType.TIMED_MUTED, null, account, rs -> {
|
MastodonHelper.scheduleBoost(ProfileActivity.this, MastodonHelper.ScheduleType.TIMED_MUTED, null, account, rs -> {
|
||||||
this.relationship = rs;
|
this.relationship = rs;
|
||||||
|
@ -942,7 +963,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_report) {
|
} else if (itemId == R.id.action_report) {
|
||||||
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
AlertDialog.Builder builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
||||||
builderInner.setTitle(R.string.report_account);
|
builderInner.setTitle(R.string.report_account);
|
||||||
//Text for report
|
//Text for report
|
||||||
EditText input = new EditText(ProfileActivity.this);
|
EditText input = new EditText(ProfileActivity.this);
|
||||||
|
@ -962,7 +983,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
builderInner.show();
|
builderInner.show();
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_block) {
|
} else if (itemId == R.id.action_block) {
|
||||||
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
AlertDialog.Builder builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
||||||
if (relationship != null) {
|
if (relationship != null) {
|
||||||
if (relationship.blocking) {
|
if (relationship.blocking) {
|
||||||
builderInner.setTitle(stringArrayConf[5]);
|
builderInner.setTitle(stringArrayConf[5]);
|
||||||
|
@ -974,15 +995,6 @@ public class ProfileActivity extends BaseActivity {
|
||||||
} else {
|
} else {
|
||||||
doActionAccount = action.NOTHING;
|
doActionAccount = action.NOTHING;
|
||||||
}
|
}
|
||||||
} else if (itemId == R.id.action_block_instance) {
|
|
||||||
builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
|
||||||
doActionAccount = action.BLOCK_DOMAIN;
|
|
||||||
String domain = account.acct.split("@")[1];
|
|
||||||
builderInner.setMessage(getString(R.string.block_domain_confirm_message, domain));
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (doAction != action.NOTHING && builderInner != null) {
|
|
||||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||||
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||||
String target;
|
String target;
|
||||||
|
@ -992,20 +1004,6 @@ public class ProfileActivity extends BaseActivity {
|
||||||
target = account.id;
|
target = account.id;
|
||||||
}
|
}
|
||||||
switch (doActionAccount) {
|
switch (doActionAccount) {
|
||||||
case MUTE:
|
|
||||||
accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target, true, 0)
|
|
||||||
.observe(ProfileActivity.this, relationShip -> {
|
|
||||||
this.relationship = relationShip;
|
|
||||||
updateAccount();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case UNMUTE:
|
|
||||||
accountsVM.unmute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target)
|
|
||||||
.observe(ProfileActivity.this, relationShip -> {
|
|
||||||
this.relationship = relationShip;
|
|
||||||
updateAccount();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
accountsVM.block(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target)
|
accountsVM.block(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target)
|
||||||
.observe(ProfileActivity.this, relationShip -> {
|
.observe(ProfileActivity.this, relationShip -> {
|
||||||
|
@ -1020,13 +1018,28 @@ public class ProfileActivity extends BaseActivity {
|
||||||
updateAccount();
|
updateAccount();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case BLOCK_DOMAIN:
|
|
||||||
accountsVM.addDomainBlocks(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
builderInner.show();
|
builderInner.show();
|
||||||
|
} else if (itemId == R.id.action_block_instance) {
|
||||||
|
AlertDialog.Builder builderInner = new AlertDialog.Builder(ProfileActivity.this, Helper.dialogStyle());
|
||||||
|
String domain = account.acct.split("@")[1];
|
||||||
|
builderInner.setMessage(getString(R.string.block_domain_confirm_message, domain));
|
||||||
|
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||||
|
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||||
|
String target;
|
||||||
|
if (item.getItemId() == R.id.action_block_instance) {
|
||||||
|
target = account.acct.split("@")[1];
|
||||||
|
} else {
|
||||||
|
target = account.id;
|
||||||
|
}
|
||||||
|
accountsVM.addDomainBlocks(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, target);
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
builderInner.show();
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1863,14 +1863,18 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
AlertDialog.Builder builderInner = new AlertDialog.Builder(context, Helper.dialogStyle());
|
AlertDialog.Builder builderInner = new AlertDialog.Builder(context, Helper.dialogStyle());
|
||||||
builderInner.setTitle(stringArrayConf[0]);
|
builderInner.setTitle(stringArrayConf[0]);
|
||||||
builderInner.setMessage(statusToDeal.account.acct);
|
builderInner.setMessage(statusToDeal.account.acct);
|
||||||
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
builderInner.setNeutralButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||||
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id, null, null)
|
builderInner.setNegativeButton(R.string.keep_notifications, (dialog, which) -> accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id, false, null)
|
||||||
|
.observe((LifecycleOwner) context, relationShip -> {
|
||||||
|
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
||||||
|
Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show();
|
||||||
|
}));
|
||||||
|
builderInner.setPositiveButton(R.string.action_mute, (dialog, which) -> accountsVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.account.id, null, null)
|
||||||
.observe((LifecycleOwner) context, relationShip -> {
|
.observe((LifecycleOwner) context, relationShip -> {
|
||||||
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
sendAction(context, Helper.ARG_STATUS_ACCOUNT_ID_DELETED, null, statusToDeal.account.id);
|
||||||
Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show();
|
Toasty.info(context, context.getString(R.string.toast_mute), Toasty.LENGTH_LONG).show();
|
||||||
}));
|
}));
|
||||||
builderInner.show();
|
builderInner.show();
|
||||||
|
|
||||||
} else if (itemId == R.id.action_mute_conversation) {
|
} else if (itemId == R.id.action_mute_conversation) {
|
||||||
if (statusToDeal.muted) {
|
if (statusToDeal.muted) {
|
||||||
statusesVM.unMute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_unmute_conversation)).show());
|
statusesVM.unMute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_unmute_conversation)).show());
|
||||||
|
|
|
@ -1915,4 +1915,5 @@
|
||||||
<string name="unpin_timeline_description">Are you sure to unpin that timeline?</string>
|
<string name="unpin_timeline_description">Are you sure to unpin that timeline?</string>
|
||||||
<string name="action_pinned_delete">Delete the pinned timelines?</string>
|
<string name="action_pinned_delete">Delete the pinned timelines?</string>
|
||||||
<string name="domains">Domains</string>
|
<string name="domains">Domains</string>
|
||||||
|
<string name="keep_notifications">Keep notifications</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue