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).
This commit is contained in:
Daniel Martí 2013-10-08 14:56:09 +02:00
parent 1011c8fadc
commit 6e622e59ab
3 changed files with 68 additions and 21 deletions

View File

@ -43,4 +43,19 @@
android:layout_height="wrap_content"
android:singleLine="false" />
<TextView
android:id="@+id/antifeatures"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="14sp"
android:textStyle="bold"
android:text="@string/antifeatures_list" />
<TextView
android:id="@+id/antifeatures_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false" />
</LinearLayout>

View File

@ -103,17 +103,27 @@
<string name="download_cancelled">Download cancelled</string>
<string name="antifeatures">Anti-Features</string>
<string name="antifeatures_list">This application has the following anti-features:</string>
<string name="antiads">Advertising</string>
<string name="antiadslong">Show apps that contain advertising</string>
<string name="antiadslist">This app contains advertising</string>
<string name="antitrack">Tracking</string>
<string name="antitracklong">Show apps that track and report your activity</string>
<string name="antitracklist">This app tracks and reports your activity</string>
<string name="antinonfreead">Add-ons</string>
<string name="antinonfreeadlong">Show apps that promote non-free add-ons</string>
<string name="antinonfreeadlist">This app promotes non-free add-ons</string>
<string name="antinonfreenet">Network Services</string>
<string name="antinonfreenetlong">Show apps that promote non-free network services</string>
<string name="antinonfreenetlist">This app promotes non-free network services</string>
<string name="antinonfreedep">Dependencies</string>
<string name="antinonfreedeplong">Show apps that depend on other non-free apps</string>
<string name="antinonfreedeplist">This app depends on other non-free apps</string>
<string name="display">Display</string>

View File

@ -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("<li><b>"+af+"</b>: "+descAntiFeature(af)+"</li>");
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