Add Device Support Information to Feedback Intent #2494 (#2499)

* Add Device Support Information to Feedback Intent #2494

* Update Device Support Information for Feedback Intent #2494

* Update Device Support Information and used common method for Feedback Intent #2494

* Optimise code for Device Support Information for Feedback Intent #2494
This commit is contained in:
Madhur Gupta 2019-02-27 01:49:59 +05:30 committed by Vivek Maskara
parent ad4c444c92
commit 5a9cce0f79
4 changed files with 58 additions and 16 deletions

View file

@ -70,10 +70,12 @@ public class CommonsApplication extends Application {
public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com"; public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com";
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback"; public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App Feedback";
public static final String NOTIFICATION_CHANNEL_ID_ALL = "CommonsNotificationAll"; public static final String NOTIFICATION_CHANNEL_ID_ALL = "CommonsNotificationAll";
public static final String FEEDBACK_EMAIL_TEMPLATE_HEADER = "-- Technical information --";
/** /**
* Constants End * Constants End
*/ */

View file

@ -42,32 +42,50 @@ public class CommonsLogSender extends LogsSender {
* @return String with extra meta information useful for debugging * @return String with extra meta information useful for debugging
*/ */
@Override @Override
protected String getExtraInfo() { public String getExtraInfo() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("App Version Name: ")
.append(ConfigUtils.getVersionNameWithSha(context)) // Getting API Level
builder.append("API level: ")
.append(DeviceInfoUtil.getAPILevel())
.append("\n"); .append("\n");
builder.append("User Name: ") // Getting Android Version
.append(sessionManager.getUserName()) builder.append("Android version: ")
.append("\n"); .append(DeviceInfoUtil.getAndroidVersion())
builder.append("Network Type: ")
.append(DeviceInfoUtil.getConnectionType(context))
.append("\n"); .append("\n");
// Getting Device Manufacturer
builder.append("Device manufacturer: ") builder.append("Device manufacturer: ")
.append(DeviceInfoUtil.getDeviceManufacturer()) .append(DeviceInfoUtil.getDeviceManufacturer())
.append("\n"); .append("\n");
// Getting Device Model
builder.append("Device model: ") builder.append("Device model: ")
.append(DeviceInfoUtil.getDeviceModel()) .append(DeviceInfoUtil.getDeviceModel())
.append("\n"); .append("\n");
builder.append("Android Version: ") // Getting Device Name
.append(DeviceInfoUtil.getAndroidVersion()) builder.append("Device: ")
.append(DeviceInfoUtil.getDevice())
.append("\n"); .append("\n");
// Getting Network Type
builder.append("Network type: ")
.append(DeviceInfoUtil.getConnectionType(context))
.append("\n");
// Getting App Version
builder.append("App version name: ")
.append(ConfigUtils.getVersionNameWithSha(context))
.append("\n");
// Getting Username
builder.append("User name: ")
.append(sessionManager.getUserName())
.append("\n");
return builder.toString(); return builder.toString();
} }
} }

View file

@ -34,12 +34,13 @@ import fr.free.nrw.commons.R;
import fr.free.nrw.commons.WelcomeActivity; import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.achievements.AchievementsActivity; import fr.free.nrw.commons.achievements.AchievementsActivity;
import fr.free.nrw.commons.auth.LoginActivity; import fr.free.nrw.commons.auth.LoginActivity;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.bookmarks.BookmarksActivity; import fr.free.nrw.commons.bookmarks.BookmarksActivity;
import fr.free.nrw.commons.category.CategoryImagesActivity; import fr.free.nrw.commons.category.CategoryImagesActivity;
import fr.free.nrw.commons.contributions.MainActivity; import fr.free.nrw.commons.contributions.MainActivity;
import fr.free.nrw.commons.kvstore.BasicKvStore; import fr.free.nrw.commons.kvstore.BasicKvStore;
import fr.free.nrw.commons.logging.CommonsLogSender;
import fr.free.nrw.commons.settings.SettingsActivity; import fr.free.nrw.commons.settings.SettingsActivity;
import fr.free.nrw.commons.utils.ConfigUtils;
import timber.log.Timber; import timber.log.Timber;
public abstract class NavigationBaseActivity extends BaseActivity public abstract class NavigationBaseActivity extends BaseActivity
@ -55,6 +56,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
@BindView(R.id.drawer_layout) @BindView(R.id.drawer_layout)
DrawerLayout drawerLayout; DrawerLayout drawerLayout;
@Inject @Named("application_preferences") BasicKvStore applicationKvStore; @Inject @Named("application_preferences") BasicKvStore applicationKvStore;
@Inject CommonsLogSender commonsLogSender;
private ActionBarDrawerToggle toggle; private ActionBarDrawerToggle toggle;
@ -187,14 +189,18 @@ public abstract class NavigationBaseActivity extends BaseActivity
return true; return true;
case R.id.action_feedback: case R.id.action_feedback:
drawerLayout.closeDrawer(navigationView); drawerLayout.closeDrawer(navigationView);
String technicalInfo = commonsLogSender.getExtraInfo();
Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO); Intent feedbackIntent = new Intent(Intent.ACTION_SENDTO);
feedbackIntent.setType("message/rfc822"); feedbackIntent.setType("message/rfc822");
feedbackIntent.setData(Uri.parse("mailto:")); feedbackIntent.setData(Uri.parse("mailto:"));
feedbackIntent.putExtra(Intent.EXTRA_EMAIL, feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
new String[]{CommonsApplication.FEEDBACK_EMAIL}); new String[]{CommonsApplication.FEEDBACK_EMAIL});
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, CommonsApplication.FEEDBACK_EMAIL_SUBJECT);
ConfigUtils.getVersionNameWithSha(getApplicationContext()))); feedbackIntent.putExtra(Intent.EXTRA_TEXT, String.format(
"\n\n%s\n%s", CommonsApplication.FEEDBACK_EMAIL_TEMPLATE_HEADER, technicalInfo));
try { try {
startActivity(feedbackIntent); startActivity(feedbackIntent);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {

View file

@ -62,7 +62,7 @@ public class DeviceInfoUtil {
* @return * @return
*/ */
public static String getDeviceModel() { public static String getDeviceModel() {
return Build.DEVICE; return Build.MODEL;
} }
/** /**
@ -72,4 +72,20 @@ public class DeviceInfoUtil {
public static String getAndroidVersion() { public static String getAndroidVersion() {
return Build.VERSION.RELEASE; return Build.VERSION.RELEASE;
} }
/**
* Get API Level. Eg. 26
* @return
*/
public static String getAPILevel() {
return Build.VERSION.SDK;
}
/**
* Get Device.
* @return
*/
public static String getDevice() {
return Build.DEVICE;
}
} }