Skip to content

Commit

Permalink
Merge pull request #810 from nextcloud/github-debug-info
Browse files Browse the repository at this point in the history
update gradle / add debug information to github issue
  • Loading branch information
David-Development authored Jan 11, 2020
2 parents c58de3a + 7fe7284 commit 0e46708
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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;
Expand All @@ -20,6 +23,12 @@
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;

Expand All @@ -33,13 +42,16 @@
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;
Expand Down Expand Up @@ -287,12 +299,17 @@ private void bindNotificationPreferences(PreferenceFragmentCompat prefFrag)
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;
});

}


Expand Down Expand Up @@ -331,6 +348,50 @@ public void onClick(DialogInterface dialog, int which) {
}
}

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;
Expand Down
2 changes: 2 additions & 0 deletions News-Android-App/src/main/res/xml/pref_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 0e46708

Please sign in to comment.