From 6e622e59ab66c20d9ab283aabcc9440b360c8b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 8 Oct 2013 14:56:09 +0200 Subject: [PATCH] Initial Anti-Feature list implementation Also, move visibility stuff from onResume to onCreate (they are only affected by preferences, i.e. onCreate will always be run since the preferences button is only in our main activity). --- res/layout/appinfo.xml | 15 +++++++ res/values/strings.xml | 10 +++++ src/org/fdroid/fdroid/AppDetails.java | 64 ++++++++++++++++++--------- 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/res/layout/appinfo.xml b/res/layout/appinfo.xml index 6c86329d0..57a695b3e 100644 --- a/res/layout/appinfo.xml +++ b/res/layout/appinfo.xml @@ -43,4 +43,19 @@ android:layout_height="wrap_content" android:singleLine="false" /> + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index cf78e881b..360004ffd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -103,17 +103,27 @@ Download cancelled Anti-Features + This application has the following anti-features: Advertising Show apps that contain advertising + This app contains advertising + Tracking Show apps that track and report your activity + This app tracks and reports your activity + Add-ons Show apps that promote non-free add-ons + This app promotes non-free add-ons + Network Services Show apps that promote non-free network services + This app promotes non-free network services + Dependencies Show apps that depend on other non-free apps + This app depends on other non-free apps Display diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 7a0235d0e..576d85035 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -244,6 +244,11 @@ public class AppDetails extends ListActivity { pref_expert = prefs.getBoolean("expert", false); pref_permissions = prefs.getBoolean("showPermissions", false); pref_incompatible = prefs.getBoolean("showIncompatible", false); + pref_antiAds = prefs.getBoolean("antiAds", false); + pref_antiTracking = prefs.getBoolean("antiTracking", false); + pref_antiNonFreeAdd = prefs.getBoolean("antiNonFreeAdd", false); + pref_antiNonFreeNet = prefs.getBoolean("antiNonFreeNet", false); + pref_antiNonFreeDep = prefs.getBoolean("antiNonFreeDep", false); ignoreToggled = false; @@ -256,6 +261,12 @@ public class AppDetails extends ListActivity { private boolean pref_incompatible; private boolean resetRequired; + private boolean pref_antiAds; + private boolean pref_antiTracking; + private boolean pref_antiNonFreeAdd; + private boolean pref_antiNonFreeNet; + private boolean pref_antiNonFreeDep; + // The signature of the installed version. private Signature mInstalledSignature; private String mInstalledSigID; @@ -471,12 +482,15 @@ public class AppDetails extends ListActivity { new HtmlTagHandler())); tv = (TextView) infoView.findViewById(R.id.appid); - tv.setText(app.id); + if (pref_expert) + tv.setText(app.id); + else + tv.setVisibility(View.GONE); tv = (TextView) infoView.findViewById(R.id.summary); tv.setText(app.summary); - if (!app.apks.isEmpty()) { + if (pref_permissions && !app.apks.isEmpty()) { tv = (TextView) infoView.findViewById(R.id.permissions_list); CommaSeparatedList permsList = app.apks.get(0).detail_permissions; @@ -500,7 +514,34 @@ public class AppDetails extends ListActivity { tv = (TextView) infoView.findViewById(R.id.permissions); tv.setText(getString( R.string.permissions_for_long, app.apks.get(0).version)); + } else { + infoView.findViewById(R.id.permissions).setVisibility(View.GONE); + infoView.findViewById(R.id.permissions_list).setVisibility(View.GONE); } + + if (app.antiFeatures != null) { + tv = (TextView) infoView.findViewById(R.id.antifeatures_list); + StringBuilder sb = new StringBuilder(); + for (String af : app.antiFeatures) + sb.append("
  • "+af+": "+descAntiFeature(af)+"
  • "); + tv.setText(Html.fromHtml(sb.toString(), null, new HtmlTagHandler())); + } else { + infoView.findViewById(R.id.antifeatures).setVisibility(View.GONE); + } + } + + private String descAntiFeature(String antiFeature) { + if (antiFeature.equals("Ads")) + return getString(R.string.antiadslist); + if (antiFeature.equals("Tracking")) + return getString(R.string.antitracklist); + if (antiFeature.equals("NonFreeNet")) + return getString(R.string.antinonfreenetlist); + if (antiFeature.equals("NonFreeAdd")) + return getString(R.string.antinonfreeadlist); + if (antiFeature.equals("NonFreeDep")) + return getString(R.string.antinonfreedeplist); + return ""; } private void updateViews() { @@ -518,13 +559,6 @@ public class AppDetails extends ListActivity { tv.setText(getString(R.string.details_installed, app.installedVersion)); - tv = (TextView) infoView.findViewById(R.id.appid); - if (pref_expert) { - tv.setVisibility(View.VISIBLE); - } else { - tv.setVisibility(View.GONE); - } - tv = (TextView) infoView.findViewById(R.id.signature); if (pref_expert && mInstalledSignature != null) { tv.setVisibility(View.VISIBLE); @@ -533,18 +567,6 @@ public class AppDetails extends ListActivity { tv.setVisibility(View.GONE); } - if (pref_permissions) { - tv = (TextView) infoView.findViewById(R.id.permissions); - tv.setVisibility(View.VISIBLE); - tv = (TextView) infoView.findViewById(R.id.permissions_list); - tv.setVisibility(View.VISIBLE); - } else { - tv = (TextView) infoView.findViewById(R.id.permissions); - tv.setVisibility(View.GONE); - tv = (TextView) infoView.findViewById(R.id.permissions_list); - tv.setVisibility(View.GONE); - } - } @Override