Skip to content

Commit

Permalink
Minor improvement for troubleshooting the app
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeveid committed Jan 4, 2025
1 parent 393993c commit a8e81f4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ android {
}
}
flavorDimensions "devicetype" // actual flavors use camelCase with first letter lowercase
def versionCodeXXX = 529
def versionCodeXXX = 530
productFlavors {
// versionCodePrefix specifies [min_api_level][bitwise_supported_screensizes s=1,m=2,l=4,xl=8]
phoneTabletPre22 {
Expand Down
112 changes: 65 additions & 47 deletions src/com/doubleyellow/scoreboard/activity/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ public class Feedback extends XActivity implements View.OnClickListener, View.On
btn.setOnClickListener(this);
}

// allow alternative way of obtaining info for if e.g. no email client is available
View btn = findViewById(R.id.cmd_email_the_developer);
btn.setLongClickable(true);
btn.setOnLongClickListener(new View.OnLongClickListener() {
@Override public boolean onLongClick(View v) {
List<String> lInfo = collectInfo();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, ListUtil.join(lInfo, "\n")); // for whatsapp
Feedback.this.startActivity(Intent.createChooser(intent, Brand.getShortName(Feedback.this) + ":")); // This actually becomes the title of the chooser
return true;
}
});

findViewById(R.id.ll_feedback) .setVisibility(View.VISIBLE);
findViewById(R.id.ll_no_there_is_a_problem).setVisibility(View.GONE);
findViewById(R.id.ll_yes_i_like ).setVisibility(View.GONE);
Expand All @@ -95,6 +109,56 @@ public class Feedback extends XActivity implements View.OnClickListener, View.On
return false;
}

private List<String> collectInfo() {
List<String> lInfo = new ArrayList<>();

// put user settings in the email
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
lInfo.add(StringUtil.lrpad("Debug Info", '=', 40));
try {
PackageInfo info = getPackageManager().getPackageInfo(this.getPackageName(), 0);

lInfo.add("App Version: " + info.versionName + " (" + info.versionCode + ")");
lInfo.add("Device API Level: " + Build.VERSION.SDK_INT);
lInfo.add("Device: " + Build.MANUFACTURER + " " + Build.MODEL + " " + Build.BRAND + " " + Build.VERSION.RELEASE);
} catch (Exception e) { }
lInfo.add("Screen Size HxW: " + ViewUtil.getScreenHeightWidthMaximum(this) + " x " + ViewUtil.getScreenHeightWidthMinimum(this));
lInfo.add("DeviceDefaultOrientation:" + ViewUtil.getDeviceDefaultOrientation(this));
lInfo.add("Resource folder: " + getString(R.string.setting_resource_folder));

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
lInfo.add(displayMetrics.toString()); // string like DisplayMetrics{density=1.5, width=480, height= 800, scaledDensity=1.2750001, xdpi=217.713 , ydpi=207.347}

if ( true ) {
lInfo.add(StringUtil.lrpad("Features", '=', 40));
final FeatureInfo[] featuresList = getPackageManager().getSystemAvailableFeatures();
for (FeatureInfo f : featuresList) {
lInfo.add(f.name);
}
}
if ( true ) {
lInfo.add(StringUtil.lrpad("Settings", '=', 40));
Map<String, ?> all = prefs.getAll();
Set<String> keys = all.keySet();
SortedSet<String> keysSorted = new TreeSet<String>(keys);
for(String key: keysSorted) {
Object val = all.get(key);
if ( key.toLowerCase().matches(".*password$")) {
val = "******"; // do not send any passwords in the feedback mail: would piss off the user
}
if ( key.endsWith("List") ) { // EventList RoundList PlayerList MatchList
val = String.format("[list of length %s]", String.valueOf(val).split("\n").length);
}
lInfo.add("|" + key + ":" + val);
}
}
if ( true ) {
lInfo.add(StringUtil.lrpad("", '=', 40));
lInfo.add("Become a tester: https://play.google.com/apps/testing/" + getPackageName());
lInfo.add(StringUtil.lrpad("", '=', 40));
}
return lInfo;
}
@Override public void onClick(View view) {
String sMarketURL = "market://details" + "?id=" + this.getPackageName();
String sPlayURL = "https://play.google.com/store/apps/details" + "?id=" + this.getPackageName();
Expand Down Expand Up @@ -145,53 +209,7 @@ public class Feedback extends XActivity implements View.OnClickListener, View.On
break;
}
case R.id.cmd_email_the_developer:
List<String> lInfo = new ArrayList<>();

// put user settings in the email
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
lInfo.add(StringUtil.lrpad("Debug Info", '=', 40));
try {
PackageInfo info = getPackageManager().getPackageInfo(this.getPackageName(), 0);

lInfo.add("App Version: " + info.versionName + " (" + info.versionCode + ")");
lInfo.add("Device API Level: " + Build.VERSION.SDK_INT);
lInfo.add("Device: " + Build.MANUFACTURER + " " + Build.MODEL + " " + Build.BRAND + " " + Build.VERSION.RELEASE);
} catch (Exception e) { }
lInfo.add("Screen Size HxW: " + ViewUtil.getScreenHeightWidthMaximum(this) + " x " + ViewUtil.getScreenHeightWidthMinimum(this));
lInfo.add("DeviceDefaultOrientation:" + ViewUtil.getDeviceDefaultOrientation(this));
lInfo.add("Resource folder: " + getString(R.string.setting_resource_folder));

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
lInfo.add(displayMetrics.toString()); // string like DisplayMetrics{density=1.5, width=480, height= 800, scaledDensity=1.2750001, xdpi=217.713 , ydpi=207.347}

if ( true ) {
lInfo.add(StringUtil.lrpad("Features", '=', 40));
final FeatureInfo[] featuresList = getPackageManager().getSystemAvailableFeatures();
for (FeatureInfo f : featuresList) {
lInfo.add(f.name);
}
}
if ( true ) {
lInfo.add(StringUtil.lrpad("Settings", '=', 40));
Map<String, ?> all = prefs.getAll();
Set<String> keys = all.keySet();
SortedSet<String> keysSorted = new TreeSet<String>(keys);
for(String key: keysSorted) {
Object val = all.get(key);
if ( key.toLowerCase().matches(".*password$")) {
val = "******"; // do not send any passwords in the feedback mail: would piss off the user
}
if ( key.endsWith("List") ) { // EventList RoundList PlayerList MatchList
val = String.format("[list of length %s]", String.valueOf(val).split("\n").length);
}
lInfo.add("|" + key + ":" + val);
}
}
if ( true ) {
lInfo.add(StringUtil.lrpad("", '=', 40));
lInfo.add("Become a tester: https://play.google.com/apps/testing/" + getPackageName());
lInfo.add(StringUtil.lrpad("", '=', 40));
}
List<String> lInfo = collectInfo();

String sendFeedbackTo = getString(R.string.developer_email);
String sSubject = Brand.getShortName(this) + " Feedback";
Expand Down
1 change: 1 addition & 0 deletions src/com/doubleyellow/scoreboard/feed/FeedFeedSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ private void fetchUrls(final JSONArray aUrls, final String sName, final JSONArra
} catch (JSONException e) {
e.printStackTrace();
changeStatus(Status.SelectFeed);
Toast.makeText(FeedFeedSelector.this, "Invalid JSON in " + sName, Toast.LENGTH_SHORT).show();
}
}
});
Expand Down
6 changes: 5 additions & 1 deletion src/com/doubleyellow/scoreboard/prefs/ExportImportPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import android.util.AttributeSet;
import android.widget.Toast;
import com.doubleyellow.android.util.ExportImport;
import com.doubleyellow.scoreboard.Brand;
import com.doubleyellow.scoreboard.R;
import com.doubleyellow.scoreboard.dialog.MyDialogBuilder;
import com.doubleyellow.util.FileUtil;
import com.doubleyellow.util.MapUtil;

Expand Down Expand Up @@ -125,9 +127,11 @@ public static void exportSettings(Context context) {
boolean bWritten = FileUtil.writeObjectToFile(fSettings, buAll);
if ( bWritten ) {
String sMsg = context.getString(R.string.x_stored_in_y, context.getString(R.string.sb_preferences), fSettings.getAbsolutePath());
MyDialogBuilder.dialogWithOkOnly(context, sMsg);
Toast.makeText(context, sMsg, Toast.LENGTH_LONG).show();
} else {
String sMsg = String.format("Could not store settings in %s", fSettings.getAbsolutePath());
MyDialogBuilder.dialogWithOkOnly(context, sMsg + "\nMaybe try and change the export location. Settings > Archive > Directory for import/export");
Toast.makeText(context, sMsg, Toast.LENGTH_LONG).show();
}
}
Expand All @@ -143,7 +147,7 @@ public static File getSettingsBinaryFile(Context context, boolean bForImport) {
Toast.makeText(context, R.string.could_not_determine_external_storage_location, Toast.LENGTH_LONG).show();
return null;
}
return new File(externalStorageDirectory, "Squore.settings.bin");
return new File(externalStorageDirectory, Brand.getShortName(context) + ".settings.bin");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ public static boolean guessShareAction(String sModelSource, Context context) {
boolean bChanged = setEnum(PreferenceKeys.shareAction, context, ShareMatchPrefs.LinkWithFullDetails);
return bChanged;
}
final int iLengthToCheck = 20;
final int iLengthToCheck = Math.max(20, sPostURL.indexOf('/', Math.min(10, sPostURL.length())));
int iMinLength = Math.min(StringUtil.size(sModelSource), StringUtil.size(sPostURL));
if ( iMinLength < iLengthToCheck ) {
// prevent StringIndexOutOfBounds
Expand Down

0 comments on commit a8e81f4

Please sign in to comment.