android/source/src/java/org/libreoffice/ColorPaletteAdapter.java |    5 +++--
 android/source/src/java/org/libreoffice/ColorPickerAdapter.java  |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 64bf055db690a4475cf49dc03800619674b891c2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Dec 12 11:45:05 2019 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Dec 12 14:30:57 2019 +0100

    tdf#115698 android: Don't modify doc on color palette initialization
    
    Previously, the call to 'ColorPaletteAdapter::setColorPalette' from
    the 'ColorPickerAdapter' constructur (via 'initializeColorPalette')
    would not just set the color palette, but also apply the color at
    index (0, 0) to the current selection, since
    'ColorPaleteAdapter::setPosition' calls
    'colorPaletteListener.applyColor' after setting the position.
    
    This is an undesirable side effect, and led to the situation described
    in tdf#115698 that cell A1 would always get black background when
    opening a spreadsheet in the Android viewer, since black is the color
    at 'color_palette[0][0]' by default and cell A1 is explicitly selected
    when Calc first opens, s. the 'CalcHeadersController' constructor.
    
    For Writer, something similar could be reproduced by selecting a
    word in a document using long-tap. If experimental editing mode was
    enabled, that word got black background (other words selected
    later didn't).
    
    To avoid this, make 'ColorPaletteAdapter::setColorPalette' just set
    the color palette and set back the values that indicate what is
    selected but don't apply any color. (And make 'setColorPalette'
    just take the palette as parameter, and set 0 for both start values,
    as the only caller was doing as well).
    
    Change-Id: I0fa720ac6550102701a2c82905c9720aab6daab2
    Reviewed-on: https://gerrit.libreoffice.org/85044
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java 
b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
index a6d250f6380d..6ec6aa138f66 100644
--- a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
+++ b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
@@ -100,9 +100,10 @@ public class ColorPaletteAdapter extends 
RecyclerView.Adapter<ColorPaletteAdapte
 
     }
 
-    public void setColorPalette(int[][] color_palette, int position1, int 
position2) {
+    public void setColorPalette(int[][] color_palette) {
         this.color_palette = color_palette;
-        setPosition(position1, position2);
+        this.upperSelectedBox = 0;
+        this.selectedBox = 0;
     }
 
     private void updateAdapter(){
diff --git a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java 
b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
index 092de46caec4..c93d5a01bbb4 100644
--- a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
+++ b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
@@ -115,7 +115,7 @@ public class ColorPickerAdapter extends 
RecyclerView.Adapter<ColorPickerAdapter.
         for (int i = 0; i < 11; i++){
             this.colorPalette[i][7] = (Color.rgb(255, 255, 255)); // last one 
is always white
         }
-        colorPaletteAdapter.setColorPalette(colorPalette, 0, 0);
+        colorPaletteAdapter.setColorPalette(colorPalette);
     }
 
     public void findSelectedTextColor(int color) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to