Dbrant has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/225323

Change subject: Fix edit pencil position when switching from RTL to LTR.
......................................................................

Fix edit pencil position when switching from RTL to LTR.

The content-rtl and content-ltr classes weren't being cleared prior to
setting the new class, causing the WebView to become confused.

Also, removed unnecessary call to setupDirectionality in our
PageLoadStrategy, since it already gets called in
loadPageOnWebViewReady().

Bug: T102046
Change-Id: I3d5c5e818fc304e94ef9dda4dcdf224cb29a9c98
---
M wikipedia/assets/bundle.js
M wikipedia/assets/preview.js
M wikipedia/src/main/java/org/wikipedia/page/JsonPageLoadStrategy.java
M www/js/rtlsupport.js
4 files changed, 20 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/23/225323/1

diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js
index 7835b9a..fc3f2be 100644
--- a/wikipedia/assets/bundle.js
+++ b/wikipedia/assets/bundle.js
@@ -373,6 +373,12 @@
 bridge.registerListener( "setDirectionality", function( payload ) {
     window.directionality = payload.contentDirection;
     var html = document.getElementsByTagName( "html" )[0];
+    // first, remove all the possible directionality classes...
+    html.classList.remove( "content-rtl" );
+    html.classList.remove( "content-ltr" );
+    html.classList.remove( "ui-rtl" );
+    html.classList.remove( "ui-ltr" );
+    // and then set the correct class based on our payload.
     html.classList.add( "content-" + window.directionality );
     html.classList.add( "ui-" + payload.uiDirection );
 } );
@@ -418,8 +424,8 @@
     return text;
 }
 
-// Returns any currently-highlighted text.
-// If no text is highlighted, returns the text of the first paragraph.
+// Returns currently highlighted text.
+// If fewer than two characters are highlighted, returns the text of the first 
paragraph.
 bridge.registerListener( "getTextSelection", function( payload ) {
     var text = window.getSelection().toString().trim();
     if (text.length < 2) {
diff --git a/wikipedia/assets/preview.js b/wikipedia/assets/preview.js
index dd266e5..753bdb2 100644
--- a/wikipedia/assets/preview.js
+++ b/wikipedia/assets/preview.js
@@ -277,6 +277,12 @@
 bridge.registerListener( "setDirectionality", function( payload ) {
     window.directionality = payload.contentDirection;
     var html = document.getElementsByTagName( "html" )[0];
+    // first, remove all the possible directionality classes...
+    html.classList.remove( "content-rtl" );
+    html.classList.remove( "content-ltr" );
+    html.classList.remove( "ui-rtl" );
+    html.classList.remove( "ui-ltr" );
+    // and then set the correct class based on our payload.
     html.classList.add( "content-" + window.directionality );
     html.classList.add( "ui-" + payload.uiDirection );
 } );
diff --git 
a/wikipedia/src/main/java/org/wikipedia/page/JsonPageLoadStrategy.java 
b/wikipedia/src/main/java/org/wikipedia/page/JsonPageLoadStrategy.java
index 8645ce0..036b206 100644
--- a/wikipedia/src/main/java/org/wikipedia/page/JsonPageLoadStrategy.java
+++ b/wikipedia/src/main/java/org/wikipedia/page/JsonPageLoadStrategy.java
@@ -552,9 +552,6 @@
             bridge.sendMessage("displayLeadSection", leadSectionPayload);
             Log.d(TAG, "Sent message 'displayLeadSection' for page: " + 
page.getDisplayTitle());
 
-            
Utils.setupDirectionality(model.getTitle().getSite().getLanguageCode(),
-                    Locale.getDefault().getLanguage(), bridge);
-
             // Hide edit pencils if anon editing is disabled by remote 
killswitch or if this is a file page
             JSONObject miscPayload = new JSONObject();
             boolean isAnonEditingDisabled = app.getRemoteConfig().getConfig()
diff --git a/www/js/rtlsupport.js b/www/js/rtlsupport.js
index d6b6a91..5199bec 100644
--- a/www/js/rtlsupport.js
+++ b/www/js/rtlsupport.js
@@ -3,6 +3,12 @@
 bridge.registerListener( "setDirectionality", function( payload ) {
     window.directionality = payload.contentDirection;
     var html = document.getElementsByTagName( "html" )[0];
+    // first, remove all the possible directionality classes...
+    html.classList.remove( "content-rtl" );
+    html.classList.remove( "content-ltr" );
+    html.classList.remove( "ui-rtl" );
+    html.classList.remove( "ui-ltr" );
+    // and then set the correct class based on our payload.
     html.classList.add( "content-" + window.directionality );
     html.classList.add( "ui-" + payload.uiDirection );
 } );

-- 
To view, visit https://gerrit.wikimedia.org/r/225323
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d5c5e818fc304e94ef9dda4dcdf224cb29a9c98
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to