Skip to content

Commit 71535c3

Browse files
Removes unsupported clients while sharing log
1 parent c9c1ba4 commit 71535c3

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import android.Manifest;
44
import android.app.AlertDialog;
55
import android.content.ActivityNotFoundException;
6+
import android.content.ComponentName;
67
import android.content.Context;
8+
import android.content.DialogInterface;
79
import android.content.Intent;
810
import android.content.SharedPreferences;
911
import android.content.pm.PackageManager;
12+
import android.content.pm.ResolveInfo;
1013
import android.net.Uri;
1114
import android.os.Build;
1215
import android.os.Bundle;
@@ -21,6 +24,8 @@
2124
import android.widget.Toast;
2225

2326
import java.io.File;
27+
import java.util.ArrayList;
28+
import java.util.List;
2429

2530
import javax.inject.Inject;
2631
import javax.inject.Named;
@@ -141,19 +146,24 @@ private void sendAppLogsViaEmail() {
141146
appLogsFile
142147
);
143148

144-
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
145-
feedbackIntent.setType("message/rfc822");
146-
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
147-
new String[]{CommonsApplication.LOGS_PRIVATE_EMAIL});
148-
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
149-
String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT,
150-
BuildConfig.VERSION_NAME));
151-
feedbackIntent.putExtra(Intent.EXTRA_STREAM,appLogsFilePath);
149+
//initialize the emailSelectorIntent
150+
Intent emailSelectorIntent = new Intent(Intent.ACTION_SENDTO);
151+
emailSelectorIntent.setData(Uri.parse("mailto:"));
152+
//initialize the emailIntent
153+
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
154+
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{CommonsApplication.FEEDBACK_EMAIL});
155+
emailIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME));
156+
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
157+
emailIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
158+
emailIntent.setSelector( emailSelectorIntent );
159+
//adding the attachment to the intent
160+
emailIntent.putExtra(Intent.EXTRA_STREAM, appLogsFilePath);
152161

153162
try {
154-
startActivity(feedbackIntent);
163+
startActivity(Intent.createChooser(emailIntent, "Send mail.."));
155164
} catch (ActivityNotFoundException e) {
156165
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
157166
}
158167
}
168+
159169
}

0 commit comments

Comments
 (0)