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_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 FEEDBACK_EMAIL_TEMPLATE_HEADER = "-- Technical information --";
/**
* Constants End
*/

View file

@ -42,32 +42,50 @@ public class CommonsLogSender extends LogsSender {
* @return String with extra meta information useful for debugging
*/
@Override
protected String getExtraInfo() {
public String getExtraInfo() {
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");
builder.append("User Name: ")
.append(sessionManager.getUserName())
.append("\n");
builder.append("Network Type: ")
.append(DeviceInfoUtil.getConnectionType(context))
// Getting Android Version
builder.append("Android version: ")
.append(DeviceInfoUtil.getAndroidVersion())
.append("\n");
// Getting Device Manufacturer
builder.append("Device manufacturer: ")
.append(DeviceInfoUtil.getDeviceManufacturer())
.append("\n");
// Getting Device Model
builder.append("Device model: ")
.append(DeviceInfoUtil.getDeviceModel())
.append("\n");
builder.append("Android Version: ")
.append(DeviceInfoUtil.getAndroidVersion())
// Getting Device Name
builder.append("Device: ")
.append(DeviceInfoUtil.getDevice())
.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();
}
}

View file

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

View file

@ -62,7 +62,7 @@ public class DeviceInfoUtil {
* @return
*/
public static String getDeviceModel() {
return Build.DEVICE;
return Build.MODEL;
}
/**
@ -72,4 +72,20 @@ public class DeviceInfoUtil {
public static String getAndroidVersion() {
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;
}
}