Issue
I have learned that using the ADB one can force the layout guides to show using the following commands:
adb shell setprop debug.layout true
adb shell service call activity 1599295570 # SYSPROPS_TRANSACTION
This allows developers to see the layout grid thanks to the SYSPROPS_TRANSACTION
code.
The examples of which can be found here
However if I want to change something like RTL (right to left) - the SYSPROPS_TRANSACTION
call does not force the re-render, I suspect because it needs to restart the activity, given that a rotation of the device will work:
adb shell setprop debug.force_rtl true
adb shell settings put system user_rotation 3 # landscape
adb shell settings put system user_rotation 0 # portrait
While I don't mind invalidating the activity I don't think I should have to be this "manual" about it. Is there a mechanism to refresh the screen without doing the rotation?
I have looked in the AOSP and found this:
private void writeToForceRtlLayoutSetting(boolean isEnabled) {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
DisplayProperties.debug_force_rtl(isEnabled);
}
which is roughly the equivalent of:
adb shell settings put global debug.force_rtl 1.0 #or 0.0 for off
But I have noticed if I do this one and a rotation it does NOT change
I have been trying to find the appropriate broadcast intent so that it would work, but I can't find one that just tells the screen to re-render
adb shell am broadcast <SOMETHING HERE WOULD BE NICE>
I took a page out of the DarkModePreference and tried to tell it that the battery charge state had changed, but you can't do that from ADB:
adb shell am broadcast android.os.action.POWER_SAVE_MODE_CHANGED
But no luck there either - no refresh happening
NOTE:
It's interesting that the layout bounds and RTL elements are grouped in the android source code, yet don't use the same behaviour when changed
Solution
I noticed that if I use
adb shell wm size
I can read the size of the window, and as a bonus, when setting it, it causes a redraw regarding right to left. So now what I do is read the window size, save it, change it a little, set it to the changed value and set it back. My script looks something like:
run("adb shell settings put global debug.force_rtl 1.0")
old_size = run("adb shell wm size")
run("adb shell wm size 100x100")
run("adb shell wm size " + old_size)
And it will force the right to left. It's a bit hacky but it works.
Answered By - Quintin Balsdon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.