[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Make text inputs in Orbot declare that they do want to opt



commit a32452e7775c28298db7bb3632da5f1e554cabed
Author: lexi <dsnake@xxxxxxxxxxxxxx>
Date:   Mon Mar 25 22:49:29 2019 -0400

    Make text inputs in Orbot declare that they do want to opt
    out of IME personalized learning. Of course, IMEs may ignore this request,
    but it's a nudge in the direction of Tor's general philosophy
    on user privacy, particularly with regards to minimizing the
    footprint that a Tor app leaves on the user's device.
---
 .../android/settings/SettingsPreferences.java      | 37 ++++++++++++++--------
 .../android/ui/NoPersonalizedLearningEditText.java | 13 ++++++++
 .../ui/hiddenservices/dialogs/AddCookieDialog.java |  4 +--
 .../ui/hiddenservices/dialogs/HSDataDialog.java    |  4 +--
 .../res/layout/layout_add_client_cookie_dialog.xml |  4 +--
 app/src/main/res/layout/layout_hs_backups_list.xml |  1 -
 app/src/main/res/layout/layout_hs_data_dialog.xml  |  8 ++---
 app/src/main/res/layout/layout_settings.xml        | 29 -----------------
 8 files changed, 47 insertions(+), 53 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
index c3b5189d..040b7b57 100644
--- a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
+++ b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
@@ -6,25 +6,26 @@ package org.torproject.android.settings;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.preference.EditTextPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
+import android.preference.PreferenceScreen;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
 
 import org.torproject.android.R;
-import org.torproject.android.service.util.Prefs;
-
-
-public class SettingsPreferences
-        extends PreferenceActivity {
-    private static final String TAG = "SettingsPreferences";
 
+public class SettingsPreferences extends PreferenceActivity {
     private ListPreference prefLocale = null;
 
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         addPreferencesFromResource(R.xml.preferences);
+        setNoPersonalizedLearningOnEditTextPreferences();
         getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
 
         prefLocale = (ListPreference) findPreference("pref_default_locale");
@@ -33,11 +34,9 @@ public class SettingsPreferences
         prefLocale.setEntries(languages.getAllNames());
         prefLocale.setEntryValues(languages.getSupportedLocales());
         prefLocale.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
-
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 String language = (String) newValue;
-
                 Intent intentResult = new Intent();
                 intentResult.putExtra("locale", language);
                 setResult(RESULT_OK, intentResult);
@@ -52,11 +51,23 @@ public class SettingsPreferences
         super.attachBaseContext(LocaleHelper.onAttach(base));
     }
 
-    @Override
-    protected void onPause() {
-        //Language.setFromPreference(this, "pref_default_locale", true);
-
-        super.onPause();
+    private void setNoPersonalizedLearningOnEditTextPreferences() {
+        PreferenceScreen preferenceScreen = getPreferenceScreen();
+        int categoryCount = preferenceScreen.getPreferenceCount();
+        for (int i = 0; i < categoryCount; i++) {
+            Preference p = preferenceScreen.getPreference(i);
+            if (p instanceof PreferenceCategory) {
+                PreferenceCategory pc = (PreferenceCategory) p;
+                int preferenceCount = pc.getPreferenceCount();
+                for (int j = 0; j < preferenceCount; j++) {
+                    p = pc.getPreference(j);
+                    if (p instanceof EditTextPreference) {
+                        EditText editText = ((EditTextPreference) p).getEditText();
+                        editText.setImeOptions(editText.getImeOptions() | EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING);
+                    }
+                }
+            }
+        }
     }
 
 }
diff --git a/app/src/main/java/org/torproject/android/ui/NoPersonalizedLearningEditText.java b/app/src/main/java/org/torproject/android/ui/NoPersonalizedLearningEditText.java
new file mode 100644
index 00000000..15d8d023
--- /dev/null
+++ b/app/src/main/java/org/torproject/android/ui/NoPersonalizedLearningEditText.java
@@ -0,0 +1,13 @@
+package org.torproject.android.ui;
+
+import android.content.Context;
+import android.support.v7.widget.AppCompatEditText;
+import android.util.AttributeSet;
+import android.view.inputmethod.EditorInfo;
+
+public class NoPersonalizedLearningEditText extends AppCompatEditText {
+    public NoPersonalizedLearningEditText(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setImeOptions(getImeOptions() | EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING);
+    }
+}
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
index 75663648..8441d53f 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/AddCookieDialog.java
@@ -29,7 +29,7 @@ public class AddCookieDialog extends DialogFragment {
                 .setTitle(R.string.client_cookies)
                 .create();
 
-        Button save = (Button) dialog_view.findViewById(R.id.cookie_dialog_save);
+        Button save = dialog_view.findViewById(R.id.cookie_dialog_save);
         save.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 String onion = ((EditText) dialog_view.findViewById(R.id.cookie_onion)).getText().toString();
@@ -45,7 +45,7 @@ public class AddCookieDialog extends DialogFragment {
             }
         });
 
-        Button cancel = (Button) dialog_view.findViewById(R.id.cookie_dialog_cancel);
+        Button cancel = dialog_view.findViewById(R.id.cookie_dialog_cancel);
         cancel.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 addCookieDialog.cancel();
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
index 98255604..01e09dff 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDataDialog.java
@@ -32,7 +32,7 @@ public class HSDataDialog extends DialogFragment {
                 .create();
 
         // Buttons action
-        Button save = (Button) dialog_view.findViewById(R.id.HSDialogSave);
+        Button save = dialog_view.findViewById(R.id.HSDialogSave);
         save.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 String serverName = ((EditText) dialog_view.findViewById(R.id.hsName)).getText().toString();
@@ -55,7 +55,7 @@ public class HSDataDialog extends DialogFragment {
             }
         });
 
-        Button cancel = (Button) dialog_view.findViewById(R.id.HSDialogCancel);
+        Button cancel = dialog_view.findViewById(R.id.HSDialogCancel);
         cancel.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 serviceDataDialog.cancel();
diff --git a/app/src/main/res/layout/layout_add_client_cookie_dialog.xml b/app/src/main/res/layout/layout_add_client_cookie_dialog.xml
index 4669a921..4561228e 100644
--- a/app/src/main/res/layout/layout_add_client_cookie_dialog.xml
+++ b/app/src/main/res/layout/layout_add_client_cookie_dialog.xml
@@ -16,7 +16,7 @@
         android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
         android:paddingLeft="5dp" />
 
-    <EditText
+    <org.torproject.android.ui.NoPersonalizedLearningEditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:inputType="text"
@@ -31,7 +31,7 @@
         android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
         android:paddingLeft="5dp" />
 
-    <EditText
+    <org.torproject.android.ui.NoPersonalizedLearningEditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:ems="10"
diff --git a/app/src/main/res/layout/layout_hs_backups_list.xml b/app/src/main/res/layout/layout_hs_backups_list.xml
index 521f381d..154195f5 100644
--- a/app/src/main/res/layout/layout_hs_backups_list.xml
+++ b/app/src/main/res/layout/layout_hs_backups_list.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
-    xmlns:tools="http://schemas.android.com/tools";
     android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="match_parent">
 
diff --git a/app/src/main/res/layout/layout_hs_data_dialog.xml b/app/src/main/res/layout/layout_hs_data_dialog.xml
index 524d69a8..8820a8d0 100644
--- a/app/src/main/res/layout/layout_hs_data_dialog.xml
+++ b/app/src/main/res/layout/layout_hs_data_dialog.xml
@@ -16,7 +16,7 @@
         android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
         android:paddingLeft="5dp" />
 
-    <EditText
+    <org.android.ui.NoPersonalizedLearningEditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:inputType="text"
@@ -31,7 +31,7 @@
         android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
         android:paddingLeft="5dp" />
 
-    <EditText
+    <org.android.ui.NoPersonalizedLearningEditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:ems="10"
@@ -46,7 +46,7 @@
         android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
         android:paddingLeft="5dp" />
 
-    <EditText
+    <org.android.ui.NoPersonalizedLearningEditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:ems="10"
@@ -84,4 +84,4 @@
 
     </LinearLayout>
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/app/src/main/res/layout/layout_settings.xml b/app/src/main/res/layout/layout_settings.xml
deleted file mode 100644
index f9b69711..00000000
--- a/app/src/main/res/layout/layout_settings.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
-    android:orientation="vertical"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
-    
-     
-        <ScrollView  android:layout_height="380px"
-            android:layout_width="fill_parent">
-            
-            <EditText android:id="@+id/textSettings"
-            android:layout_height="fill_parent"
-            android:layout_width="fill_parent"
-            android:layout_weight="1.0"
-            android:singleLine="false"
-            android:textSize="11px"
-            />	
-            
-        </ScrollView>
-            
-          <Button android:id="@+id/btnSettingsSave" 
-            android:layout_width="fill_parent" 
-            android:layout_height="40px" 
-             android:text="@string/btn_save_settings"        
-             android:layout_margin="0sp"
-      
-             
-            />
-</LinearLayout>



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits