Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed800704 authored by Qing Xia's avatar Qing Xia
Browse files

Fix Gravity toString wrong message issue

1. Bit calculation was not correct before as there are multiple bits
that can be set.
2. Changed a duplicate CLIP message as well.
3. And add an empty check.

Test: In 'dumpsys window' the gravity of the window should be correct.
Change-Id: I4b699e5d6d5d7c2beb8ac12cbd78cf2f81e70b3f
parent 62462871
Loading
Loading
Loading
Loading
+18 −15
Original line number Original line Diff line number Diff line
@@ -446,50 +446,53 @@ public class Gravity
     */
     */
    public static String toString(int gravity) {
    public static String toString(int gravity) {
        final StringBuilder result = new StringBuilder();
        final StringBuilder result = new StringBuilder();
        if ((gravity & FILL) != 0) {
        if ((gravity & FILL) == FILL) {
            result.append("FILL").append(' ');
            result.append("FILL").append(' ');
        } else {
        } else {
            if ((gravity & FILL_VERTICAL) != 0) {
            if ((gravity & FILL_VERTICAL) == FILL_VERTICAL) {
                result.append("FILL_VERTICAL").append(' ');
                result.append("FILL_VERTICAL").append(' ');
            } else {
            } else {
                if ((gravity & TOP) != 0) {
                if ((gravity & TOP) == TOP) {
                    result.append("TOP").append(' ');
                    result.append("TOP").append(' ');
                }
                }
                if ((gravity & BOTTOM) != 0) {
                if ((gravity & BOTTOM) == BOTTOM) {
                    result.append("BOTTOM").append(' ');
                    result.append("BOTTOM").append(' ');
                }
                }
            }
            }
            if ((gravity & FILL_HORIZONTAL) != 0) {
            if ((gravity & FILL_HORIZONTAL) == FILL_HORIZONTAL) {
                result.append("FILL_HORIZONTAL").append(' ');
                result.append("FILL_HORIZONTAL").append(' ');
            } else {
            } else {
                if ((gravity & START) != 0) {
                if ((gravity & START) == START) {
                    result.append("START").append(' ');
                    result.append("START").append(' ');
                } else if ((gravity & LEFT) != 0) {
                } else if ((gravity & LEFT) == LEFT) {
                    result.append("LEFT").append(' ');
                    result.append("LEFT").append(' ');
                }
                }
                if ((gravity & END) != 0) {
                if ((gravity & END) == END) {
                    result.append("END").append(' ');
                    result.append("END").append(' ');
                } else if ((gravity & RIGHT) != 0) {
                } else if ((gravity & RIGHT) == RIGHT) {
                    result.append("RIGHT").append(' ');
                    result.append("RIGHT").append(' ');
                }
                }
            }
            }
        }
        }
        if ((gravity & CENTER) != 0) {
        if ((gravity & CENTER) == CENTER) {
            result.append("CENTER").append(' ');
            result.append("CENTER").append(' ');
        } else {
        } else {
            if ((gravity & CENTER_VERTICAL) != 0) {
            if ((gravity & CENTER_VERTICAL) == CENTER_VERTICAL) {
                result.append("CENTER_VERTICAL").append(' ');
                result.append("CENTER_VERTICAL").append(' ');
            }
            }
            if ((gravity & CENTER_HORIZONTAL) != 0) {
            if ((gravity & CENTER_HORIZONTAL) == CENTER_HORIZONTAL) {
                result.append("CENTER_HORIZONTAL").append(' ');
                result.append("CENTER_HORIZONTAL").append(' ');
            }
            }
        }
        }
        if ((gravity & DISPLAY_CLIP_VERTICAL) != 0) {
        if (result.length() == 0) {
            result.append("DISPLAY_CLIP_VERTICAL").append(' ');
            result.append("NO GRAVITY").append(' ');
        }
        }
        if ((gravity & DISPLAY_CLIP_VERTICAL) != 0) {
        if ((gravity & DISPLAY_CLIP_VERTICAL) == DISPLAY_CLIP_VERTICAL) {
            result.append("DISPLAY_CLIP_VERTICAL").append(' ');
            result.append("DISPLAY_CLIP_VERTICAL").append(' ');
        }
        }
        if ((gravity & DISPLAY_CLIP_HORIZONTAL) == DISPLAY_CLIP_HORIZONTAL) {
            result.append("DISPLAY_CLIP_HORIZONTAL").append(' ');
        }
        result.deleteCharAt(result.length() - 1);
        result.deleteCharAt(result.length() - 1);
        return result.toString();
        return result.toString();
    }
    }