Made extra privacy features explicit

This commit is contained in:
M66B
2019-07-07 10:49:16 +02:00
parent bd7e879eff
commit 3a34a30cbc
9 changed files with 103 additions and 101 deletions

View File

@@ -117,7 +117,6 @@ import org.jsoup.nodes.Element;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
@@ -3371,9 +3370,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean paranoid = prefs.getBoolean("paranoid", true);
final Uri uri = getArguments().getParcelable("uri");
String title = getArguments().getString("title");
@@ -3401,6 +3397,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
final EditText etLink = view.findViewById(R.id.etLink);
final CheckBox cbSecure = view.findViewById(R.id.cbSecure);
CheckBox cbSanitize = view.findViewById(R.id.cbSanitize);
final Button btnOwner = view.findViewById(R.id.btnOwner);
final ContentLoadingProgressBar pbWait = view.findViewById(R.id.pbWait);
final TextView tvOwner = view.findViewById(R.id.tvOwner);
final TextView tvHost = view.findViewById(R.id.tvHost);
final Group grpOwner = view.findViewById(R.id.grpOwner);
@@ -3472,43 +3470,50 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
});
pbWait.setVisibility(View.GONE);
grpOwner.setVisibility(View.GONE);
btnOwner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle args = new Bundle();
args.putParcelable("uri", uri);
if (paranoid) {
// TODO: spinner
Bundle args = new Bundle();
args.putParcelable("uri", uri);
new SimpleTask<String[]>() {
@Override
protected void onPreExecute(Bundle args) {
tvOwner.setText("");
grpOwner.setVisibility(View.VISIBLE);
}
@Override
protected String[] onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
return IPInfo.getOrganization(uri);
}
@Override
protected void onExecuted(Bundle args, String[] data) {
String host = data[0];
String organization = data[1];
tvHost.setText(host);
tvOwner.setText(organization == null ? "?" : organization);
}
@Override
protected void onException(Bundle args, Throwable ex) {
if (ex instanceof UnknownHostException)
new SimpleTask<String[]>() {
@Override
protected void onPreExecute(Bundle args) {
btnOwner.setEnabled(false);
pbWait.setVisibility(View.VISIBLE);
grpOwner.setVisibility(View.GONE);
else
}
@Override
protected void onPostExecute(Bundle args) {
btnOwner.setEnabled(true);
pbWait.setVisibility(View.GONE);
grpOwner.setVisibility(View.VISIBLE);
}
@Override
protected String[] onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
return IPInfo.getOrganization(uri);
}
@Override
protected void onExecuted(Bundle args, String[] data) {
String host = data[0];
String organization = data[1];
tvHost.setText(host);
tvOwner.setText(organization == null ? "?" : organization);
}
@Override
protected void onException(Bundle args, Throwable ex) {
tvOwner.setText(ex.getMessage());
}
}.execute(getContext(), getActivity(), args, "link:domain");
}
}
}.execute(getContext(), getActivity(), args, "link:owner");
}
});
return new AlertDialog.Builder(getContext())
.setView(view)

View File

@@ -45,10 +45,11 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swCollapse;
private SwitchCompat swAutoRead;
private SwitchCompat swAutoMove;
private SwitchCompat swDisableTracking;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "swipenav", "doubletap", "autoexpand", "autoclose", "autonext",
"collapse", "autoread", "automove"
"collapse", "autoread", "automove", "disable_tracking"
};
@Override
@@ -71,6 +72,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swCollapse = view.findViewById(R.id.swCollapse);
swAutoRead = view.findViewById(R.id.swAutoRead);
swAutoMove = view.findViewById(R.id.swAutoMove);
swDisableTracking = view.findViewById(R.id.swDisableTracking);
setOptions();
@@ -149,6 +151,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swDisableTracking.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("disable_tracking", checked).apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@@ -204,5 +213,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swCollapse.setChecked(prefs.getBoolean("collapse", false));
swAutoRead.setChecked(prefs.getBoolean("autoread", false));
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
}
}

View File

@@ -24,7 +24,6 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -52,8 +51,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swSubscribedOnly;
private SwitchCompat swEnglish;
private SwitchCompat swAuthentication;
private SwitchCompat swParanoid;
private TextView tvParanoidHint;
private SwitchCompat swWatchdog;
private SwitchCompat swUpdates;
private SwitchCompat swCrashReports;
@@ -67,7 +64,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Group grpDebug;
private final static String[] RESET_OPTIONS = new String[]{
"badge", "subscriptions", "subscribed_only", "english", "authentication", "paranoid", "watchdog", "updates", "crash_reports", "debug"
"badge", "subscriptions", "subscribed_only", "english", "authentication", "watchdog", "updates", "crash_reports", "debug"
};
private final static String[] RESET_QUESTIONS = new String[]{
@@ -90,8 +87,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly);
swEnglish = view.findViewById(R.id.swEnglish);
swAuthentication = view.findViewById(R.id.swAuthentication);
swParanoid = view.findViewById(R.id.swParanoid);
tvParanoidHint = view.findViewById(R.id.tvParanoidHint);
swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates);
swCrashReports = view.findViewById(R.id.swCrashReports);
@@ -150,26 +145,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swParanoid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("paranoid", checked).apply();
}
});
final Intent faq = new Intent(Intent.ACTION_VIEW);
faq.setData(Uri.parse(Helper.FAQ_URI + "#user-content-faq86"));
faq.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (faq.resolveActivity(getContext().getPackageManager()) != null) {
tvParanoidHint.getPaint().setUnderlineText(true);
tvParanoidHint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(faq);
}
});
}
swWatchdog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -269,7 +244,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swEnglish.setChecked(prefs.getBoolean("english", false));
swAuthentication.setChecked(prefs.getBoolean("authentication", false));
swParanoid.setChecked(prefs.getBoolean("paranoid", true));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE);

View File

@@ -85,9 +85,6 @@ public class HtmlHelper {
private static final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
static String sanitize(Context context, String html, boolean show_images) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean paranoid = prefs.getBoolean("paranoid", true);
Document parsed = Jsoup.parse(html);
// <html xmlns:v="urn:schemas-microsoft-com:vml"
@@ -225,9 +222,11 @@ public class HtmlHelper {
table.tagName("div");
// Images
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
for (Element img : document.select("img")) {
// Remove link tracking pixels
if (paranoid && isTrackingPixel(img)) {
if (disable_tracking && isTrackingPixel(img)) {
String src = img.attr("src");
img.removeAttr("src");
img.tagName("a");