]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Improve the night mode WebView text selection color. https://redmine.stoutner.com...
authorSoren Stoutner <soren@stoutner.com>
Tue, 22 Jan 2019 00:58:20 +0000 (17:58 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 22 Jan 2019 00:58:20 +0000 (17:58 -0700)
app/src/main/assets/css/dark_theme.css
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/layout/about_tab_version.xml

index 95739ba737c24127bd957f3345654cad6d68fb42..9af6c54b332f893a569bf970f297c42c8fd43dd0 100644 (file)
@@ -29,6 +29,11 @@ a {
     text-decoration: none;
 }
 
     text-decoration: none;
 }
 
+/* Blue 900 */
+::selection {
+    background: #0D47A1;
+}
+
 /* Blue 600 */
 h3 {
     color: #1E88E5;
 /* Blue 600 */
 h3 {
     color: #1E88E5;
index c1463d92f9c845244fb101076ae68fe8390828e0..96098947696d915603fa7e53d69d4b4de556a812 100644 (file)
@@ -95,6 +95,7 @@ import android.webkit.ValueCallback;
 import android.webkit.WebBackForwardList;
 import android.webkit.WebChromeClient;
 import android.webkit.WebResourceResponse;
 import android.webkit.WebBackForwardList;
 import android.webkit.WebChromeClient;
 import android.webkit.WebResourceResponse;
+import android.webkit.WebSettings;
 import android.webkit.WebStorage;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
 import android.webkit.WebStorage;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
@@ -982,11 +983,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 if (nightMode) {
                     // `background-color: #212121` sets the background to be dark gray.  `color: #BDBDBD` sets the text color to be light gray.  `box-shadow: none` removes a lower underline on links
                     // used by WordPress.  `text-decoration: none` removes all text underlines.  `text-shadow: none` removes text shadows, which usually have a hard coded color.
                 if (nightMode) {
                     // `background-color: #212121` sets the background to be dark gray.  `color: #BDBDBD` sets the text color to be light gray.  `box-shadow: none` removes a lower underline on links
                     // used by WordPress.  `text-decoration: none` removes all text underlines.  `text-shadow: none` removes text shadows, which usually have a hard coded color.
-                    // `border: none` removes all borders, which can also be used to underline text.
-                    // `a {color: #1565C0}` sets links to be a dark blue.  `!important` takes precedent over any existing sub-settings.
+                    // `border: none` removes all borders, which can also be used to underline text.  `a {color: #1565C0}` sets links to be a dark blue.
+                    // `::selection {background: #0D47A1}' sets the text selection highlight color to be a dark blue. `!important` takes precedent over any existing sub-settings.
                     mainWebView.evaluateJavascript("(function() {var parent = document.getElementsByTagName('head').item(0); var style = document.createElement('style'); style.type = 'text/css'; " +
                             "style.innerHTML = '* {background-color: #212121 !important; color: #BDBDBD !important; box-shadow: none !important; text-decoration: none !important;" +
                     mainWebView.evaluateJavascript("(function() {var parent = document.getElementsByTagName('head').item(0); var style = document.createElement('style'); style.type = 'text/css'; " +
                             "style.innerHTML = '* {background-color: #212121 !important; color: #BDBDBD !important; box-shadow: none !important; text-decoration: none !important;" +
-                            "text-shadow: none !important; border: none !important;} a {color: #1565C0 !important;}'; parent.appendChild(style)})()", value -> {
+                            "text-shadow: none !important; border: none !important;} a {color: #1565C0 !important;} ::selection {background: #0D47A1 !important;}'; parent.appendChild(style)})()", value -> {
                                 // Initialize a handler to display `mainWebView`.
                                 Handler displayWebViewHandler = new Handler();
 
                                 // Initialize a handler to display `mainWebView`.
                                 Handler displayWebViewHandler = new Handler();
 
@@ -1221,10 +1222,15 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Hide zoom controls.
         mainWebView.getSettings().setDisplayZoomControls(false);
 
         // Hide zoom controls.
         mainWebView.getSettings().setDisplayZoomControls(false);
 
-        // Set `mainWebView` to use a wide viewport.  Otherwise, some web pages will be scrunched and some content will render outside the screen.
+        // Don't allow mixed content (HTTP and HTTPS) on the same website.
+        if (Build.VERSION.SDK_INT >= 21) {
+            mainWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
+        }
+
+        // Set the WebView to use a wide viewport.  Otherwise, some web pages will be scrunched and some content will render outside the screen.
         mainWebView.getSettings().setUseWideViewPort(true);
 
         mainWebView.getSettings().setUseWideViewPort(true);
 
-        // Set `mainWebView` to load in overview mode (zoomed out to the maximum width).
+        // Set the WebView to load in overview mode (zoomed out to the maximum width).
         mainWebView.getSettings().setLoadWithOverviewMode(true);
 
         // Explicitly disable geolocation.
         mainWebView.getSettings().setLoadWithOverviewMode(true);
 
         // Explicitly disable geolocation.
index 1df1ef0de5c236a557859acb3ecb3bcdb29022de..31d6bf78a134d6050bbc22574b75b3c06cd45bc6 100644 (file)
@@ -65,6 +65,7 @@
                 android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:textColor="?attr/aboutText"
                 android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:textColor="?attr/aboutText"
+                android:textIsSelectable="true"
                 android:layout_below="@id/privacy_browser_textview"
                 android:layout_toEndOf="@id/icon" />
         </RelativeLayout>
                 android:layout_below="@id/privacy_browser_textview"
                 android:layout_toEndOf="@id/icon" />
         </RelativeLayout>
             <TextView
                 android:id="@+id/brand"
                 android:layout_height="wrap_content"
             <TextView
                 android:id="@+id/brand"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/manufacturer"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/manufacturer"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/model"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/model"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/device"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/device"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/bootloader"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/bootloader"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/radio"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/radio"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <!-- Software. -->
             <TextView
 
             <!-- Software. -->
             <TextView
             <TextView
                 android:id="@+id/android"
                 android:layout_height="wrap_content"
             <TextView
                 android:id="@+id/android"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/security_patch"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/security_patch"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/build"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/build"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/webview"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/webview"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/orbot"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/orbot"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/open_keychain"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/open_keychain"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content"/>
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <!-- Block Lists. -->
             <TextView
 
             <!-- Block Lists. -->
             <TextView
             <TextView
                 android:id="@+id/easylist"
                 android:layout_height="wrap_content"
             <TextView
                 android:id="@+id/easylist"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/easyprivacy"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/easyprivacy"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/fanboy_annoyance"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/fanboy_annoyance"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/fanboy_social"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/fanboy_social"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/ultraprivacy"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/ultraprivacy"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <!-- Package Signature. -->
             <TextView
 
             <!-- Package Signature. -->
             <TextView
             <TextView
                 android:id="@+id/certificate_issuer_dn"
                 android:layout_height="wrap_content"
             <TextView
                 android:id="@+id/certificate_issuer_dn"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_subject_dn"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_subject_dn"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_start_date"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_start_date"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_end_date"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_end_date"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_version"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_version"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_serial_number"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_serial_number"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
 
             <TextView
                 android:id="@+id/certificate_signature_algorithm"
                 android:layout_height="wrap_content"
 
             <TextView
                 android:id="@+id/certificate_signature_algorithm"
                 android:layout_height="wrap_content"
-                android:layout_width="wrap_content" />
+                android:layout_width="wrap_content"
+                android:textIsSelectable="true" />
         </LinearLayout>
     </LinearLayout>
 </ScrollView>
\ No newline at end of file
         </LinearLayout>
     </LinearLayout>
 </ScrollView>
\ No newline at end of file