mirror of
https://github.com/stom79/exodus-android-app
synced 2025-01-30 00:55:23 +01:00
Fix crash when versionName is null in PackageInfo use versionCode instead (workaround)
Fix Missing permissions in the lists in reports
This commit is contained in:
parent
1370b4e798
commit
c897cc1dd1
@ -178,6 +178,7 @@ public class ApplicationListAdapter extends RecyclerView.Adapter {
|
||||
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
long versionCode = packageInfo.versionCode;
|
||||
|
||||
//get logo
|
||||
try {
|
||||
@ -195,11 +196,17 @@ public class ApplicationListAdapter extends RecyclerView.Adapter {
|
||||
appItemBinding.appPermissionNb.setText(context.getString(R.string.permissions) + " " + String.valueOf(0));
|
||||
}
|
||||
//get reports
|
||||
Report report = DatabaseManager.getInstance(context).getReportFor(packageName, versionName);
|
||||
Report report = null;
|
||||
if(versionName != null)
|
||||
report = DatabaseManager.getInstance(context).getReportFor(packageName, versionName);
|
||||
else
|
||||
report = DatabaseManager.getInstance(context).getReportFor(packageName, versionCode);
|
||||
if(report != null) {
|
||||
Set<Tracker> trackers = DatabaseManager.getInstance(context).getTrackers(report.trackers);
|
||||
appItemBinding.appTrackerNb.setText(context.getString(R.string.trackers) + " " + trackers.size());
|
||||
if(!report.version.equals(data.versionName)) {
|
||||
if(versionName != null && !report.version.equals(data.versionName)) {
|
||||
appItemBinding.otherVersion.setVisibility(View.VISIBLE);
|
||||
} else if (versionName == null && report.versionCode != versionCode) {
|
||||
appItemBinding.otherVersion.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,10 @@ public class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAd
|
||||
|
||||
void setupData(Permission permission) {
|
||||
if(permission != null) {
|
||||
permissionItemBinding.permissionName.setText(permission.name);
|
||||
if(permission.name != null)
|
||||
permissionItemBinding.permissionName.setText(permission.name);
|
||||
else
|
||||
permissionItemBinding.permissionName.setText(permission.fullName);
|
||||
permissionItemBinding.permissionDescription.setText(permission.description);
|
||||
manageExpanded(permission);
|
||||
permissionItemBinding.mainLayout.setOnClickListener((View.OnClickListener) v -> {
|
||||
|
@ -87,6 +87,7 @@ public class ReportFragment extends Fragment {
|
||||
Context context = reportBinding.getRoot().getContext();
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
long versionCode = packageInfo.versionCode;
|
||||
|
||||
//setup logo
|
||||
try {
|
||||
@ -120,10 +121,10 @@ public class ReportFragment extends Fragment {
|
||||
permission.description = permissionInfo.loadDescription(packageManager).toString();
|
||||
if(permissionInfo.loadLabel(packageManager) != null)
|
||||
permission.name = permissionInfo.loadLabel(packageManager).toString();
|
||||
requestedPermissions.add(permission);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
requestedPermissions.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +138,11 @@ public class ReportFragment extends Fragment {
|
||||
reportBinding.trackerLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
//get trackers
|
||||
Report report = DatabaseManager.getInstance(context).getReportFor(packageName,versionName);
|
||||
Report report = null;
|
||||
if(versionName != null)
|
||||
report = DatabaseManager.getInstance(context).getReportFor(packageName,versionName);
|
||||
else
|
||||
report = DatabaseManager.getInstance(context).getReportFor(packageName,versionCode);
|
||||
Set<Tracker> trackers = null;
|
||||
if(report != null) {
|
||||
trackers = DatabaseManager.getInstance(context).getTrackers(report.trackers);
|
||||
|
@ -225,6 +225,47 @@ public class DatabaseManager extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public Report getReportFor(String packageName, long version) {
|
||||
String[] columns = {"id"};
|
||||
String where = "package = ?";
|
||||
String[] whereArgs = {packageName};
|
||||
Cursor cursor = getReadableDatabase().query("applications",columns,where,whereArgs,null,null,null);
|
||||
if(cursor.moveToFirst()) {
|
||||
long appId = cursor.getLong(0);
|
||||
cursor.close();
|
||||
where = "app_id = ? and version_code = ?";
|
||||
whereArgs = new String[2];
|
||||
whereArgs[0] = String.valueOf(appId);
|
||||
whereArgs[1] = String.valueOf(version);
|
||||
String order = "id ASC";
|
||||
cursor = getReadableDatabase().query("reports",columns,where,whereArgs,null,null,order);
|
||||
long reportId;
|
||||
if(cursor.moveToFirst()) {
|
||||
reportId = cursor.getLong(0);
|
||||
} else {
|
||||
columns = new String[2];
|
||||
columns[0] = "id";
|
||||
columns[1] = "creation";
|
||||
where = "app_id = ?";
|
||||
whereArgs = new String[1];
|
||||
whereArgs[0] = String.valueOf(appId);
|
||||
order = "creation DESC";
|
||||
//search a recent reports
|
||||
cursor = getReadableDatabase().query("reports",columns,where,whereArgs,null,null,order);
|
||||
if(cursor.moveToFirst()) {
|
||||
reportId = cursor.getLong(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return getReport(reportId);
|
||||
|
||||
} else {
|
||||
cursor.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Report getReport(long reportId) {
|
||||
String where = "id = ?";
|
||||
String[] whereArgs = {String.valueOf(reportId)};
|
||||
|
Loading…
x
Reference in New Issue
Block a user