diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java index f14cffe3..db783de3 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsActivity.java @@ -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; diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java index 96da5e0a..9577f01a 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java @@ -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 excludedSettings = Arrays.asList(EDT_USERNAME_STRING, EDT_PASSWORD_STRING, EDT_OWNCLOUDROOTPATH_STRING, Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING); + Map allEntries = mPrefs.getAll(); + for (Map.Entry 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 { private ProgressDialog pd; diff --git a/News-Android-App/src/main/res/xml/pref_about.xml b/News-Android-App/src/main/res/xml/pref_about.xml index d3afd95a..8a4e0c9a 100644 --- a/News-Android-App/src/main/res/xml/pref_about.xml +++ b/News-Android-App/src/main/res/xml/pref_about.xml @@ -22,9 +22,11 @@ android:summary="@string/pref_report_issue_summary" app:iconSpaceReserved="false"> +