Merge pull request #2708 from deltachat/adb/issue-2707

allow to resend attachments from chat profile
This commit is contained in:
Asiel Díaz Benítez
2023-10-04 07:56:31 -04:00
committed by GitHub
6 changed files with 44 additions and 14 deletions
+4
View File
@@ -27,4 +27,8 @@
<item android:id="@+id/save"
android:title="@string/menu_export_attachments"
app:showAsAction="never"/>
<item android:id="@+id/menu_resend"
android:title="@string/resend"
app:showAsAction="never" />
</menu>
@@ -478,20 +478,6 @@ public class ConversationFragment extends MessageSelectorFragment
}
}
private void handleResendMessage(final Set<DcMsg> dcMsgsSet) {
int[] ids = DcMsg.msgSetToIds(dcMsgsSet);
if (dcContext.resendMsgs(ids)) {
actionMode.finish();
Toast.makeText(getContext(), R.string.sending, Toast.LENGTH_SHORT).show();
} else {
new AlertDialog.Builder(getContext())
.setMessage(dcContext.getLastError())
.setCancelable(false)
.setPositiveButton(android.R.string.ok, null)
.show();
}
}
private void reloadList() {
reloadList(false);
}
@@ -7,6 +7,7 @@ import android.os.AsyncTask;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
@@ -115,4 +116,18 @@ public abstract class MessageSelectorFragment
protected void handleShare(final DcMsg dcMsg) {
DcHelper.openForViewOrShare(getContext(), dcMsg.getId(), Intent.ACTION_SEND);
}
protected void handleResendMessage(final Set<DcMsg> dcMsgsSet) {
int[] ids = DcMsg.msgSetToIds(dcMsgsSet);
if (dcContext.resendMsgs(ids)) {
actionMode.finish();
Toast.makeText(getContext(), R.string.sending, Toast.LENGTH_SHORT).show();
} else {
new AlertDialog.Builder(getContext())
.setMessage(dcContext.getLastError())
.setCancelable(false)
.setPositiveButton(android.R.string.ok, null)
.show();
}
}
}
@@ -204,6 +204,15 @@ public class ProfileDocumentsFragment
menu.findItem(R.id.show_in_chat).setVisible(singleSelection);
menu.findItem(R.id.share).setVisible(singleSelection);
boolean canResend = true;
for (DcMsg messageRecord : messageRecords) {
if (!messageRecord.isOutgoing()) {
canResend = false;
break;
}
}
menu.findItem(R.id.menu_resend).setVisible(canResend);
boolean webxdcApp = singleSelection && messageRecords.iterator().next().getType() == DcMsg.DC_MSG_WEBXDC;
menu.findItem(R.id.menu_add_to_home_screen).setVisible(webxdcApp);
}
@@ -259,6 +268,9 @@ public class ProfileDocumentsFragment
case R.id.save:
handleSaveAttachment(getListAdapter().getSelectedMedia());
return true;
case R.id.menu_resend:
handleResendMessage(getListAdapter().getSelectedMedia());
return true;
}
return false;
}
@@ -197,6 +197,15 @@ public class ProfileGalleryFragment
menu.findItem(R.id.details).setVisible(singleSelection);
menu.findItem(R.id.show_in_chat).setVisible(singleSelection);
menu.findItem(R.id.share).setVisible(singleSelection);
boolean canResend = true;
for (DcMsg messageRecord : messageRecords) {
if (!messageRecord.isOutgoing()) {
canResend = false;
break;
}
}
menu.findItem(R.id.menu_resend).setVisible(canResend);
}
private ProfileGalleryAdapter getListAdapter() {
@@ -246,6 +255,9 @@ public class ProfileGalleryFragment
case R.id.save:
handleSaveAttachment(getListAdapter().getSelectedMedia());
return true;
case R.id.menu_resend:
handleResendMessage(getListAdapter().getSelectedMedia());
return true;
}
return false;
}
@@ -271,6 +271,7 @@ public class ProfileSettingsFragment extends Fragment
menu.findItem(R.id.show_in_chat).setVisible(false);
menu.findItem(R.id.save).setVisible(false);
menu.findItem(R.id.share).setVisible(false);
menu.findItem(R.id.menu_resend).setVisible(false);
mode.setTitle("1");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {