mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-09-15 08:20:18 +03:00
Allow to disable the quote button grouped with boost icon
This commit is contained in:
parent
5030bda394
commit
8274556404
4 changed files with 141 additions and 83 deletions
|
@ -438,6 +438,102 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
sendAction(context, Helper.ARG_STATUS_ACTION, statusToDeal, null);
|
sendAction(context, Helper.ARG_STATUS_ACTION, statusToDeal, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage tap on reblog icon
|
||||||
|
* @param context
|
||||||
|
* @param v
|
||||||
|
* @param statusesVM
|
||||||
|
* @param searchVM
|
||||||
|
* @param holder
|
||||||
|
* @param adapter
|
||||||
|
* @param statusToDeal
|
||||||
|
* @param warnNoMedia
|
||||||
|
* @param confirmBoost
|
||||||
|
* @param remote
|
||||||
|
*/
|
||||||
|
private static void reblogTap(Context context,
|
||||||
|
View v,
|
||||||
|
StatusesVM statusesVM,
|
||||||
|
SearchVM searchVM,
|
||||||
|
StatusViewHolder holder,
|
||||||
|
RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
|
||||||
|
Status statusToDeal,
|
||||||
|
boolean warnNoMedia, boolean confirmBoost, boolean remote) {
|
||||||
|
boolean needToWarnForMissingDescription = false;
|
||||||
|
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
||||||
|
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||||
|
if (attachment.description == null || attachment.description.trim().length() == 0) {
|
||||||
|
needToWarnForMissingDescription = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (confirmBoost || needToWarnForMissingDescription) {
|
||||||
|
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context);
|
||||||
|
|
||||||
|
if (statusToDeal.reblogged) {
|
||||||
|
alt_bld.setMessage(context.getString(R.string.reblog_remove));
|
||||||
|
} else {
|
||||||
|
if (!needToWarnForMissingDescription) {
|
||||||
|
alt_bld.setMessage(context.getString(R.string.reblog_add));
|
||||||
|
} else {
|
||||||
|
alt_bld.setMessage(context.getString(R.string.reblog_missing_description));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
|
||||||
|
if (remote) {
|
||||||
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||||
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
|
.observe((LifecycleOwner) context, results -> {
|
||||||
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
||||||
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
||||||
|
} else {
|
||||||
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (statusToDeal.reblogged) {
|
||||||
|
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
||||||
|
} else {
|
||||||
|
((SparkButton) v).playAnimation();
|
||||||
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||||
|
AlertDialog alert = alt_bld.create();
|
||||||
|
alert.show();
|
||||||
|
} else {
|
||||||
|
if (remote) {
|
||||||
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||||
|
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
||||||
|
.observe((LifecycleOwner) context, results -> {
|
||||||
|
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
||||||
|
Status fetchedStatus = results.statuses.get(0);
|
||||||
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
||||||
|
} else {
|
||||||
|
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (statusToDeal.reblogged) {
|
||||||
|
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
||||||
|
} else {
|
||||||
|
((SparkButton) v).playAnimation();
|
||||||
|
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
||||||
|
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage status, this method is also reused in notifications timelines
|
* Manage status, this method is also reused in notifications timelines
|
||||||
|
@ -486,7 +582,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
boolean displayCounters = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COUNTER_FAV_BOOST), false);
|
boolean displayCounters = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COUNTER_FAV_BOOST), false);
|
||||||
boolean removeLeftMargin = sharedpreferences.getBoolean(context.getString(R.string.SET_REMOVE_LEFT_MARGIN), false);
|
boolean removeLeftMargin = sharedpreferences.getBoolean(context.getString(R.string.SET_REMOVE_LEFT_MARGIN), false);
|
||||||
boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||||
boolean displayQuote = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_QUOTES) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
boolean displayQuote = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_QUOTE) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||||
boolean displayReactions = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_REACTIONS) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
boolean displayReactions = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_REACTIONS) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||||
boolean compactButtons = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COMPACT_ACTION_BUTTON), false);
|
boolean compactButtons = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COMPACT_ACTION_BUTTON), false);
|
||||||
boolean originalDateForBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_BOOST_ORIGINAL_DATE), true);
|
boolean originalDateForBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_BOOST_ORIGINAL_DATE), true);
|
||||||
|
@ -1107,86 +1203,20 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
holder.binding.actionButtonBoost.setOnClickListener(v -> {
|
holder.binding.actionButtonBoost.setOnClickListener(v -> {
|
||||||
|
if(displayQuote) {
|
||||||
PopupMenu popupMenu = new PopupMenu(context, v);
|
PopupMenu popupMenu = new PopupMenu(context, v);
|
||||||
popupMenu.getMenuInflater().inflate(R.menu.menu_boost_or_quote, popupMenu.getMenu());
|
popupMenu.getMenuInflater().inflate(R.menu.menu_boost_or_quote, popupMenu.getMenu());
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
popupMenu.setOnMenuItemClickListener(item -> {
|
||||||
@Override
|
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == R.id.action_reblog) {
|
if (itemId == R.id.action_reblog) {
|
||||||
boolean needToWarnForMissingDescription = false;
|
reblogTap(context,
|
||||||
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
v,
|
||||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
statusesVM,
|
||||||
if (attachment.description == null || attachment.description.trim().length() == 0) {
|
searchVM,
|
||||||
needToWarnForMissingDescription = true;
|
holder,
|
||||||
break;
|
adapter,
|
||||||
}
|
statusToDeal,
|
||||||
}
|
warnNoMedia, confirmBoost, remote);
|
||||||
}
|
|
||||||
if (confirmBoost || needToWarnForMissingDescription) {
|
|
||||||
AlertDialog.Builder alt_bld = new MaterialAlertDialogBuilder(context);
|
|
||||||
|
|
||||||
if (statusToDeal.reblogged) {
|
|
||||||
alt_bld.setMessage(context.getString(R.string.reblog_remove));
|
|
||||||
} else {
|
|
||||||
if (!needToWarnForMissingDescription) {
|
|
||||||
alt_bld.setMessage(context.getString(R.string.reblog_add));
|
|
||||||
} else {
|
|
||||||
alt_bld.setMessage(context.getString(R.string.reblog_missing_description));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
alt_bld.setPositiveButton(R.string.yes, (dialog, id) -> {
|
|
||||||
if (remote) {
|
|
||||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
|
||||||
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
|
||||||
.observe((LifecycleOwner) context, results -> {
|
|
||||||
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
|
||||||
Status fetchedStatus = results.statuses.get(0);
|
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
|
||||||
} else {
|
|
||||||
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (statusToDeal.reblogged) {
|
|
||||||
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
|
||||||
} else {
|
|
||||||
((SparkButton) v).playAnimation();
|
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dialog.dismiss();
|
|
||||||
});
|
|
||||||
alt_bld.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
|
||||||
AlertDialog alert = alt_bld.create();
|
|
||||||
alert.show();
|
|
||||||
} else {
|
|
||||||
if (remote) {
|
|
||||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
|
||||||
searchVM.search(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.uri, null, "statuses", false, true, false, 0, null, null, 1)
|
|
||||||
.observe((LifecycleOwner) context, results -> {
|
|
||||||
if (results != null && results.statuses != null && results.statuses.size() > 0) {
|
|
||||||
Status fetchedStatus = results.statuses.get(0);
|
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, fetchedStatus.id, null)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, true));
|
|
||||||
} else {
|
|
||||||
Toasty.info(context, context.getString(R.string.toast_error_search), Toasty.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (statusToDeal.reblogged) {
|
|
||||||
statusesVM.unReblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.UNREBLOG_ACTION, statusToDeal, _status, false));
|
|
||||||
} else {
|
|
||||||
((SparkButton) v).playAnimation();
|
|
||||||
statusesVM.reblog(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id, null)
|
|
||||||
.observe((LifecycleOwner) context, _status -> manageAction(context, adapter, holder, CrossActionHelper.TypeOfCrossAction.REBLOG_ACTION, statusToDeal, _status, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_quote) {
|
} else if (itemId == R.id.action_quote) {
|
||||||
Intent intent = new Intent(context, ComposeActivity.class);
|
Intent intent = new Intent(context, ComposeActivity.class);
|
||||||
|
@ -1201,9 +1231,19 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
|
} else {
|
||||||
|
reblogTap(context,
|
||||||
|
v,
|
||||||
|
statusesVM,
|
||||||
|
searchVM,
|
||||||
|
holder,
|
||||||
|
adapter,
|
||||||
|
statusToDeal,
|
||||||
|
warnNoMedia, confirmBoost, remote);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
holder.binding.actionButtonBoost.setChecked(statusToDeal.reblogged);
|
holder.binding.actionButtonBoost.setChecked(statusToDeal.reblogged);
|
||||||
//---> FAVOURITE/UNFAVOURITE
|
//---> FAVOURITE/UNFAVOURITE
|
||||||
|
|
|
@ -94,6 +94,12 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
||||||
SET_DISPLAY_TRANSLATE.setChecked(checked);
|
SET_DISPLAY_TRANSLATE.setChecked(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SwitchPreferenceCompat SET_DISPLAY_QUOTE = findPreference(getString(R.string.SET_DISPLAY_QUOTE));
|
||||||
|
if (SET_DISPLAY_QUOTE != null) {
|
||||||
|
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_QUOTE) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||||
|
SET_DISPLAY_QUOTE.setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
SwitchPreferenceCompat SET_PIXELFED_PRESENTATION = findPreference(getString(R.string.SET_PIXELFED_PRESENTATION));
|
SwitchPreferenceCompat SET_PIXELFED_PRESENTATION = findPreference(getString(R.string.SET_PIXELFED_PRESENTATION));
|
||||||
if (SET_PIXELFED_PRESENTATION != null) {
|
if (SET_PIXELFED_PRESENTATION != null) {
|
||||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_PIXELFED_PRESENTATION) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_PIXELFED_PRESENTATION) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||||
|
@ -125,6 +131,12 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
||||||
editor.putBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_TRANSLATE.isChecked());
|
editor.putBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_TRANSLATE.isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (key.compareToIgnoreCase(getString(R.string.SET_DISPLAY_QUOTE)) == 0) {
|
||||||
|
SwitchPreferenceCompat SET_DISPLAY_QUOTE = findPreference(getString(R.string.SET_DISPLAY_QUOTE));
|
||||||
|
if (SET_DISPLAY_QUOTE != null) {
|
||||||
|
editor.putBoolean(getString(R.string.SET_DISPLAY_QUOTE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_QUOTE.isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (key.compareToIgnoreCase(getString(R.string.SET_PIXELFED_PRESENTATION)) == 0) {
|
if (key.compareToIgnoreCase(getString(R.string.SET_PIXELFED_PRESENTATION)) == 0) {
|
||||||
SwitchPreferenceCompat SET_PIXELFED_PRESENTATION = findPreference(getString(R.string.SET_PIXELFED_PRESENTATION));
|
SwitchPreferenceCompat SET_PIXELFED_PRESENTATION = findPreference(getString(R.string.SET_PIXELFED_PRESENTATION));
|
||||||
if (SET_PIXELFED_PRESENTATION != null) {
|
if (SET_PIXELFED_PRESENTATION != null) {
|
||||||
|
|
|
@ -1258,6 +1258,7 @@
|
||||||
<string name="SET_PIXELFED_FULL_MEDIA" translatable="false">SET_PIXELFED_FULL_MEDIA</string>
|
<string name="SET_PIXELFED_FULL_MEDIA" translatable="false">SET_PIXELFED_FULL_MEDIA</string>
|
||||||
|
|
||||||
<string name="SET_DISPLAY_QUOTES" translatable="false">SET_DISPLAY_QUOTES</string>
|
<string name="SET_DISPLAY_QUOTES" translatable="false">SET_DISPLAY_QUOTES</string>
|
||||||
|
<string name="SET_DISPLAY_QUOTE" translatable="false">SET_DISPLAY_QUOTE</string>
|
||||||
<string name="SET_DISPLAY_REACTIONS" translatable="false">SET_DISPLAY_REACTIONS</string>
|
<string name="SET_DISPLAY_REACTIONS" translatable="false">SET_DISPLAY_REACTIONS</string>
|
||||||
|
|
||||||
<string name="SET_DISPLAY_TRANSLATE" translatable="false">SET_DISPLAY_TRANSLATE</string>
|
<string name="SET_DISPLAY_TRANSLATE" translatable="false">SET_DISPLAY_TRANSLATE</string>
|
||||||
|
|
|
@ -148,7 +148,12 @@
|
||||||
app:key="@string/SET_DISPLAY_TRANSLATE"
|
app:key="@string/SET_DISPLAY_TRANSLATE"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:title="@string/set_display_translate_indication" />
|
app:title="@string/set_display_translate_indication" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="@string/SET_DISPLAY_QUOTE"
|
||||||
|
app:singleLineTitle="false"
|
||||||
|
app:title="@string/set_display_quote_indication" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:defaultValue="FEDILAB"
|
app:defaultValue="FEDILAB"
|
||||||
app:dialogTitle="@string/translator"
|
app:dialogTitle="@string/translator"
|
||||||
|
|
Loading…
Reference in a new issue