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: Adjustments in regards to Anton's comments Created Feb. 27, 2019, 5 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.ActivityNotFoundException;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.content.pm.PackageInfo;
24 import android.content.pm.PackageManager;
25 import android.content.res.Resources;
26 import android.net.Uri;
27 import android.os.Build;
28 import android.preference.Preference;
29 import android.util.AttributeSet;
30
31 public class FeedbackPreference extends Preference
32 {
33 private static final String EMAIL_RECIPIENT = "support@adblockplus.org";
34 private static final String EMAIL_SUBJECT = "Feedback - Adblock Browser for An droid";
35
36 public FeedbackPreference(Context context)
37 {
38 super(context);
39 }
40
41 public FeedbackPreference(Context context, AttributeSet attrs)
42 {
43 super(context, attrs);
44 }
45
46 public FeedbackPreference(Context context, AttributeSet attrs, int defStyle)
47 {
48 super(context, attrs, defStyle);
49 }
50
51 @Override
52 protected void onClick()
53 {
54 final String emailBody = generateEmailBody();
55 final Intent intent = new Intent(Intent.ACTION_VIEW);
56 final Uri data = Uri.parse(
57 "mailto:" + EMAIL_RECIPIENT + "?subject=" + EMAIL_SUBJECT + "&body=" + e mailBody);
58 intent.setData(data);
59 try
60 {
61 getContext().startActivity(intent);
62 }
63 catch (ActivityNotFoundException e)
64 {
65 }
66 }
67
68 private String generateEmailBody()
69 {
70 String emailBody = "\n\n\nUseful information:";
71 emailBody += "\n App Version: " + getAppVersion();
72 emailBody += "\n Android Version: " + Build.VERSION.RELEASE;
73 emailBody += "\n Device Model: " + Build.MANUFACTURER + " - " + Build.MODEL;
74 emailBody += "\n Language: " + getLanguage();
75 return emailBody;
76 }
77
78 private String getAppVersion()
79 {
80 try
81 {
82 final PackageInfo packageInfo = getContext().getPackageManager().getPackag eInfo(
83 getContext().getPackageName(), 0);
84 return packageInfo.versionName;
85 }
86 catch (PackageManager.NameNotFoundException e)
87 {
88 }
89 return "";
90 }
91
92 private String getLanguage()
93 {
94 return Resources.getSystem().getConfiguration().locale.toString();
95 }
96 }
OLDNEW

Powered by Google App Engine
This is Rietveld