From f6b5ef66efffc91b5e036ea090ba0fb4eb8da351 Mon Sep 17 00:00:00 2001 From: Schoumi Date: Tue, 8 Jan 2019 18:23:16 +0100 Subject: [PATCH] add color for trackers number and permissions number in reports --- .../fragments/ReportFragment.java | 61 ++++++++++++----- app/src/main/res/drawable/square_green.xml | 6 ++ app/src/main/res/drawable/square_red.xml | 6 ++ app/src/main/res/drawable/square_yellow.xml | 6 ++ app/src/main/res/layout/report.xml | 65 +++++++++++++++---- 5 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 app/src/main/res/drawable/square_green.xml create mode 100644 app/src/main/res/drawable/square_red.xml create mode 100644 app/src/main/res/drawable/square_yellow.xml diff --git a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java index 28f3282..f25d3cd 100644 --- a/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java +++ b/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/fragments/ReportFragment.java @@ -100,13 +100,22 @@ public class ReportFragment extends Fragment { reportBinding.name.setText(packageManager.getApplicationLabel(packageInfo.applicationInfo)); //setup permissions number - String permissions_text; - if (packageInfo.requestedPermissions != null && packageInfo.requestedPermissions.length > 0) - permissions_text = context.getString(R.string.permissions) + " " + String.valueOf(packageInfo.requestedPermissions.length); - else - permissions_text = context.getString(R.string.permissions); + if (packageInfo.requestedPermissions != null) { + reportBinding.permissionsNb.setText(String.valueOf(packageInfo.requestedPermissions.length)); + reportBinding.permissionsNb.setVisibility(View.VISIBLE); + } + else { + reportBinding.permissionsNb.setVisibility(View.GONE); + } - reportBinding.permissionsTitle.setText(permissions_text); + if(packageInfo.requestedPermissions != null){ + if(packageInfo.requestedPermissions.length == 0) + reportBinding.permissionsNb.setBackgroundResource(R.drawable.square_green); + else if(packageInfo.requestedPermissions.length < 5) + reportBinding.permissionsNb.setBackgroundResource(R.drawable.square_yellow); + else + reportBinding.permissionsNb.setBackgroundResource(R.drawable.square_red); + } //setup permissions list List requestedPermissions = null; @@ -151,12 +160,20 @@ public class ReportFragment extends Fragment { reportBinding.trackerLayout.setVisibility(View.GONE); } //setup trackers report - String trackers_text; - if(trackers != null && trackers.size() > 0) - trackers_text = context.getString(R.string.trackers)+" "+String.valueOf(trackers.size()); - else - trackers_text = context.getString(R.string.trackers); - reportBinding.trackersTitle.setText(trackers_text); + if(trackers != null) { + reportBinding.trackersNb.setText(String.valueOf(trackers.size())); + reportBinding.trackersNb.setVisibility(View.VISIBLE); + } else { + reportBinding.trackersNb.setVisibility(View.GONE); + } + if(trackers != null){ + if(trackers.size() == 0) + reportBinding.trackersNb.setBackgroundResource(R.drawable.square_green); + else if(trackers.size() < 5) + reportBinding.trackersNb.setBackgroundResource(R.drawable.square_yellow); + else + reportBinding.trackersNb.setBackgroundResource(R.drawable.square_red); + } //setup trackers lists reportBinding.trackers.setLayoutManager(new LinearLayoutManager(context)); @@ -171,14 +188,26 @@ public class ReportFragment extends Fragment { reportBinding.creator.setVisibility(View.GONE); //setup installed - String installed_str = context.getString(R.string.installed) +" "+ versionName; + String installed_str = ""; + if(versionName != null) + installed_str = context.getString(R.string.installed) +" "+ versionName; + else + installed_str = context.getString(R.string.installed) +" "+ String.valueOf(versionCode); reportBinding.installedVersion.setText(installed_str); //setup reportversion reportBinding.reportVersion.setVisibility(View.VISIBLE); - if(report != null && !report.version.equals(versionName)) { - String report_str = context.getString(R.string.report_version)+" "+report.version; - reportBinding.reportVersion.setText(report_str); + if(report != null) { + String report_str = ""; + if (versionName != null && !report.version.equals(versionName)) { + report_str = context.getString(R.string.report_version) + " " + report.version; + } else if (versionName == null && report.versionCode != versionCode) { + report_str = context.getString(R.string.report_version) + " " + report.versionCode; + } + if(!report_str.isEmpty()) + reportBinding.reportVersion.setText(report_str); + else + reportBinding.reportVersion.setVisibility(View.GONE); } else reportBinding.reportVersion.setVisibility(View.GONE); diff --git a/app/src/main/res/drawable/square_green.xml b/app/src/main/res/drawable/square_green.xml new file mode 100644 index 0000000..696bdf3 --- /dev/null +++ b/app/src/main/res/drawable/square_green.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/square_red.xml b/app/src/main/res/drawable/square_red.xml new file mode 100644 index 0000000..bc428ee --- /dev/null +++ b/app/src/main/res/drawable/square_red.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/square_yellow.xml b/app/src/main/res/drawable/square_yellow.xml new file mode 100644 index 0000000..58dcd14 --- /dev/null +++ b/app/src/main/res/drawable/square_yellow.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/report.xml b/app/src/main/res/layout/report.xml index 6ee4300..37d80c9 100644 --- a/app/src/main/res/layout/report.xml +++ b/app/src/main/res/layout/report.xml @@ -84,14 +84,35 @@ android:layout_weight="50" android:orientation="vertical"> - + > + + + + + - + android:background="@color/colorPrimary" + > + + + +