Merge pull request #810 from nextcloud/github-debug-info

update gradle / add debug information to github issue
This commit is contained in:
David Luhmer 2020-01-11 17:36:34 +01:00 committed by GitHub
commit 0e46708c54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 2 deletions

View file

@ -98,6 +98,7 @@ public class SettingsActivity extends AppCompatActivity {
public static final String SP_SWIPE_LEFT_ACTION_DEFAULT = "2";
public static final String CB_VERSION = "cb_version";
public static final String CB_REPORT_ISSUE = "cb_reportIssue";
protected @Inject SharedPreferences mPrefs;

View file

@ -7,6 +7,9 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
@ -20,6 +23,12 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.TwoStatePreference;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
@ -33,13 +42,16 @@ import static de.luhmer.owncloudnewsreader.LoginDialogActivity.RESULT_LOGIN;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_MARK_AS_READ_WHILE_SCROLLING_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_NAVIGATE_WITH_VOLUME_BUTTONS_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_OLED_MODE;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_REPORT_ISSUE;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_SHOWONLYUNREAD_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_SHOW_NOTIFICATION_NEW_ARTICLES_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_SYNCONSTARTUP_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.CB_VERSION;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_CLEAR_CACHE;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_PASSWORD_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.EDT_USERNAME_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.LV_CACHE_IMAGES_OFFLINE_STRING;
import static de.luhmer.owncloudnewsreader.SettingsActivity.PREF_SERVER_SETTINGS;
import static de.luhmer.owncloudnewsreader.SettingsActivity.PREF_SYNC_SETTINGS;
@ -287,12 +299,17 @@ public class SettingsFragment extends PreferenceFragmentCompat {
private void bindAboutPreferences(final PreferenceFragmentCompat prefFrag) {
prefFrag.findPreference(CB_VERSION).setSummary(version);
Preference changelogPreference = prefFrag.findPreference(CB_VERSION);
changelogPreference.setOnPreferenceClickListener(preference -> {
DialogFragment dialog = new VersionInfoDialogFragment();
dialog.show(prefFrag.getActivity().getFragmentManager(), "VersionChangelogDialogFragment");
return true;
});
findPreference(CB_REPORT_ISSUE).setOnPreferenceClickListener(preference -> {
openBugReport();
return true;
});
}
@ -331,6 +348,50 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}
}
private void openBugReport() {
String title = "";
String body = "";
String debugInfo = "Please describe your bug here...\n\n---\n";
try {
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
debugInfo += "\nApp Version: " + pInfo.versionName;
debugInfo += "\nApp Version Code: " + pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
debugInfo += "\n\n---\n";
debugInfo += "\nSSO enabled: " + mPrefs.getBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, false);
debugInfo += "\n\n---\n";
debugInfo += "\nOS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
debugInfo += "\nOS API Level: " + android.os.Build.VERSION.SDK_INT;
debugInfo += "\nDevice: " + android.os.Build.DEVICE;
debugInfo += "\nModel (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")";
debugInfo += "\n\n---\n\n";
List<String> excludedSettings = Arrays.asList(EDT_USERNAME_STRING, EDT_PASSWORD_STRING, EDT_OWNCLOUDROOTPATH_STRING, Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING);
Map<String, ?> allEntries = mPrefs.getAll();
for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
String key =entry.getKey();
if(!excludedSettings.contains(key)) {
debugInfo += entry + "\n";
}
}
try {
body = URLEncoder.encode(debugInfo,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/nextcloud/news-android/issues/new?title=" + title + "&body=" + body));
startActivity(browserIntent);
}
public static class ResetDatabaseAsyncTask extends AsyncTask<Void, Void, Void> {
private ProgressDialog pd;

View file

@ -22,9 +22,11 @@
android:summary="@string/pref_report_issue_summary"
app:iconSpaceReserved="false">
<!--
<intent
android:action="android.intent.action.VIEW"
android:data="https://github.com/nextcloud/news-android/issues" />
-->
</Preference>
<Preference

View file

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}