Log editor infos while debugging

Useful when debugging why the keyboard doesn't work as expected with a
specific app.
This commit is contained in:
Jules Aguillon 2022-03-15 11:49:32 +01:00
parent 9bb7c7e66f
commit f9cd4ca2d8
2 changed files with 21 additions and 0 deletions

View File

@ -13,4 +13,6 @@
<dimen name="emoji_grid_height">250dp</dimen> <dimen name="emoji_grid_height">250dp</dimen>
<dimen name="emoji_text_size">28dp</dimen> <dimen name="emoji_text_size">28dp</dimen>
<dimen name="extra_horizontal_margin">0dp</dimen> <dimen name="extra_horizontal_margin">0dp</dimen>
<bool name="debug_logs" product="debug">true</bool>
<bool name="debug_logs" product="default">false</bool>
</resources> </resources>

View File

@ -18,6 +18,8 @@ import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
import android.util.Log;
import android.util.LogPrinter;
import java.util.List; import java.util.List;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -25,12 +27,16 @@ import java.util.Set;
public class Keyboard2 extends InputMethodService public class Keyboard2 extends InputMethodService
implements SharedPreferences.OnSharedPreferenceChangeListener implements SharedPreferences.OnSharedPreferenceChangeListener
{ {
static private final String TAG = "Keyboard2";
private Keyboard2View _keyboardView; private Keyboard2View _keyboardView;
private int _currentTextLayout; private int _currentTextLayout;
private ViewGroup _emojiPane = null; private ViewGroup _emojiPane = null;
private Config _config; private Config _config;
private boolean _debug_logs = false;
private KeyboardData getLayout(int resId) private KeyboardData getLayout(int resId)
{ {
return KeyboardData.load(getResources(), resId); return KeyboardData.load(getResources(), resId);
@ -47,6 +53,7 @@ public class Keyboard2 extends InputMethodService
_config.refresh(this); _config.refresh(this);
_keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard);
_keyboardView.reset(); _keyboardView.reset();
_debug_logs = getResources().getBoolean(R.bool.debug_logs);
} }
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm) private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
@ -182,6 +189,16 @@ public class Keyboard2 extends InputMethodService
} }
} }
private void log_editor_info(EditorInfo info)
{
LogPrinter p = new LogPrinter(Log.DEBUG, TAG);
info.dump(p, "");
if (info.extras != null)
Log.d(TAG, "extras: "+info.extras.toString());
Log.d(TAG, "swapEnterActionKey: "+_config.swapEnterActionKey);
Log.d(TAG, "actionLabel: "+_config.actionLabel);
}
@Override @Override
public void onStartInputView(EditorInfo info, boolean restarting) public void onStartInputView(EditorInfo info, boolean restarting)
{ {
@ -192,6 +209,8 @@ public class Keyboard2 extends InputMethodService
else else
_keyboardView.setKeyboard(getLayout(_currentTextLayout)); _keyboardView.setKeyboard(getLayout(_currentTextLayout));
setInputView(_keyboardView); setInputView(_keyboardView);
if (_debug_logs)
log_editor_info(info);
} }
@Override @Override