Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: mobile/android/base/java/org/adblockplus/browser/FeedbackPreference.java

Issue 30018598: Issue 7281 - Remove Google+ links (Closed)
Patch Set: Created Feb. 26, 2019, 12:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.browser;
19
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.pm.PackageInfo;
23 import android.content.pm.PackageManager;
24 import android.content.res.Resources;
25 import android.net.Uri;
26 import android.os.Build;
27 import android.preference.Preference;
28 import android.util.AttributeSet;
29
30 public class FeedbackPreference extends Preference
31 {
32 private static final String EMAIL_RECIPIENT = "support@adblockplus.org";
33 private static final String EMAIL_SUBJECT = "Feedback - Adblock Browser for An droid";
34
35 public FeedbackPreference(Context context)
36 {
37 super(context);
38 }
39
40 public FeedbackPreference(Context context, AttributeSet attrs)
41 {
42 super(context, attrs);
43 }
44
45 public FeedbackPreference(Context context, AttributeSet attrs, int defStyle)
46 {
47 super(context, attrs, defStyle);
48 }
49
50 @Override
51 protected void onClick()
52 {
53 final String emailBody = generateEmailBody();
54 final Intent intent = new Intent(Intent.ACTION_VIEW);
55 final Uri data = Uri.parse(
56 "mailto:" + EMAIL_RECIPIENT + "?subject=" + EMAIL_SUBJECT + "&body=" + e mailBody);
57 intent.setData(data);
58 getContext().startActivity(intent);
anton 2019/02/26 12:52:54 do we assume email client is always installed? oth
diegocarloslima 2019/02/27 16:37:57 I don't think that an exception will ever occur, b
59 }
60
61 private String generateEmailBody()
62 {
63 String emailBody = "\n\n\nUseful information:";
64 emailBody += "\n App Version: " + getAppVersion();
65 emailBody += "\n Android Version: " + Build.VERSION.RELEASE;
66 emailBody += "\n Device Model: " + Build.MANUFACTURER + " - " + Build.MODEL;
67 emailBody += "\n Language: " + getLanguage();
68 return emailBody;
69 }
70
71 private String getAppVersion()
72 {
73 try
74 {
75 final PackageInfo packageInfo = getContext().getPackageManager().getPackag eInfo(
76 getContext().getPackageName(), 0);
77 return packageInfo.versionName;
78 }
79 catch (PackageManager.NameNotFoundException e)
80 {
81 }
82 return "";
83 }
84
85 private String getLanguage()
86 {
87 // TODO: Replace by ConfigurationCompat when the support lib is >= 26.1.0
anton 2019/02/26 12:52:54 afaik somewhere in code style guide there is requi
diegocarloslima 2019/02/27 16:37:57 Acknowledged.
88 return Resources.getSystem().getConfiguration().locale.toString();
89 }
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld