mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Merge 4.0-release into master (#5028)
* Fix string for custom selector * Fix bug #4950 back arrow still present on top-level activity (#4952) * Fix bug #4949 by correctly setting previous db version number (#4956) * Fix bug #4949 by correctly setting previous db version number * Fix failing tests * Fix bug #4959 by correctly setting previous db version number and updating the current db version (#4960) * Fix bug #4957 (#4961) * Update library to new version that handles older Java VMs Fixes #4972 I believe. * Versioning for v4.0.0 * Changelog for v4.0.0 * Fix bug #4984 Added queries for package name for Android API 30+ (#4987) * Update mapbox sdk version (#4989) * Versioning for v4.0.1 * Changelog for v4.0.1 * Remove network type information from NetworkUtils (#4996) * Remove network type information from NetworkUtils * Ignore dependent tests * Fix #4992 invert the equals condition to be null safe (#4995) * Fix java.lang.NullPointerException for username in ContributionBoundaryCallback (#5003) * Fix failing tests for PR #5003 (#5004) * Fix java.lang.NullPointerException for username in ContributionBoundaryCallback * Fix failing tests * Update Room DB Version (#5011) * Fix #5001 (#5010) * Fix DB update issue (#5016) * [WIP] Fix both timezone problem and saved date problem (#5019) * Fix both timezone problem and saved date problem * Fixaccidental test code and add comments * Add issue link to the comments * Fix format issue and null checks * Versioning for v4.0.2 * Changelog for v4.0.2 * Add "Report Violation" menu option (#5025) * Add "Report Violation" menu option * Update email template * Update email address * Fixed typo Co-authored-by: Josephine Lim <josephinelim86@gmail.com> * Versioning for v4.0.3 * Changelog for v4.0.3 Co-authored-by: Josephine Lim <josephinelim86@gmail.com> Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com> Co-authored-by: neslihanturan <tur.neslihan@gmail.com>
This commit is contained in:
parent
1de8968fa8
commit
3cdfdcffe1
29 changed files with 406 additions and 72 deletions
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.media;
|
|||
import static fr.free.nrw.commons.Utils.handleWebUrl;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -12,7 +13,9 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
|
@ -22,6 +25,7 @@ import androidx.viewpager.widget.ViewPager;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.Media;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
|
|
@ -33,7 +37,6 @@ import fr.free.nrw.commons.contributions.MainActivity;
|
|||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
import fr.free.nrw.commons.utils.DownloadUtils;
|
||||
import fr.free.nrw.commons.utils.ImageUtils;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
|
|
@ -211,11 +214,83 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
|||
ProfileActivity.startYourself(getActivity(), m.getUser(),
|
||||
!Objects.equals(sessionManager.getUserName(), m.getUser()));
|
||||
}
|
||||
return true;
|
||||
case R.id.menu_view_report:
|
||||
showReportDialog(m);
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void showReportDialog(final Media media) {
|
||||
if (media == null) {
|
||||
return;
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
|
||||
final String[] values = requireContext().getResources()
|
||||
.getStringArray(R.array.report_violation_options);
|
||||
builder.setTitle(R.string.report_violation);
|
||||
builder.setItems(R.array.report_violation_options, (dialog, which) -> {
|
||||
sendReportEmail(media, values[which]);
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void sendReportEmail(final Media media, final String type) {
|
||||
final String technicalInfo = getTechInfo(media, type);
|
||||
|
||||
final Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO);
|
||||
feedbackIntent.setType("message/rfc822");
|
||||
feedbackIntent.setData(Uri.parse("mailto:"));
|
||||
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
|
||||
new String[]{CommonsApplication.REPORT_EMAIL});
|
||||
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
|
||||
CommonsApplication.REPORT_EMAIL_SUBJECT);
|
||||
feedbackIntent.putExtra(Intent.EXTRA_TEXT, technicalInfo);
|
||||
try {
|
||||
startActivity(feedbackIntent);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private String getTechInfo(final Media media, final String type) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Report type: ")
|
||||
.append(type)
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("Image that you want to report: ")
|
||||
.append(media.getImageUrl())
|
||||
.append("\n\n");
|
||||
|
||||
builder.append("User that you want to report: ")
|
||||
.append(media.getAuthor())
|
||||
.append("\n\n");
|
||||
|
||||
if (sessionManager.getUserName() != null) {
|
||||
builder.append("Your username: ")
|
||||
.append(sessionManager.getUserName())
|
||||
.append("\n\n");
|
||||
}
|
||||
|
||||
builder.append("Violation reason: ")
|
||||
.append("\n");
|
||||
|
||||
builder.append("----------------------------------------------")
|
||||
.append("\n")
|
||||
.append("(please write reason here)")
|
||||
.append("\n")
|
||||
.append("----------------------------------------------")
|
||||
.append("\n\n")
|
||||
.append("Thank you for your report! Our team will investigate as soon as possible.")
|
||||
.append("\n")
|
||||
.append("Please note that images also have a `Nominate for deletion` button.");
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the media as the device's wallpaper if the imageUrl is not null
|
||||
* Fails silently if setting the wallpaper fails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue