Skip to content

Commit

Permalink
fix NullPointerException
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/osfans/trime/ime/core/Trime.java
  • Loading branch information
tumuyan authored and Bambooin committed Oct 19, 2021
1 parent 288573b commit 8fe8c71
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions app/src/main/java/com/osfans/trime/ime/core/Trime.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,44 +481,49 @@ private void showCompositionView() {
}

private void loadBackground() {
final Config imeConfig = getImeConfig();
final Config mConfig = getImeConfig();
final int orientation = getResources().getConfiguration().orientation;
final int[] padding =
imeConfig.getKeyboardPadding(
oneHandMode, orientation == Configuration.ORIENTATION_LANDSCAPE);

if (mPopupWindow != null) {
final Drawable d =
mConfig.getDrawable(
"text_back_color",
"layout/border",
"border_color",
"layout/round_corner",
"layout/alpha");
if (d != null) mPopupWindow.setBackgroundDrawable(d);
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
mPopupWindow.setElevation(mConfig.getPixel("layout/elevation"));
}

if (mCandidateRoot != null) {
final Drawable d2 =
mConfig.getDrawable(
"candidate_background",
"candidate_border",
"candidate_border_color",
"candidate_border_round",
null);
if (d2 != null) mCandidateRoot.setBackground(d2);
}

if (inputRootBinding == null) return;

int[] padding =
mConfig.getKeyboardPadding(oneHandMode, orientation == Configuration.ORIENTATION_LANDSCAPE);
Timber.i("padding= %s %s %s", padding[0], padding[1], padding[2]);
mainKeyboardView.setPadding(padding[0], 0, padding[1], padding[2]);

final Drawable d =
imeConfig.getDrawable(
"text_back_color",
"layout/border",
"border_color",
"layout/round_corner",
"layout/alpha");
if (d != null) mPopupWindow.setBackgroundDrawable(d);
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
mPopupWindow.setElevation(imeConfig.getPixel("layout/elevation"));

final Drawable d2 =
imeConfig.getDrawable(
"candidate_background",
"candidate_border",
"candidate_border_color",
"candidate_border_round",
null);

if (d2 != null) mCandidateRoot.setBackground(d2);

final Drawable d3 = imeConfig.getDrawable_("root_background");
final Drawable d3 = mConfig.getDrawable_("root_background");
if (d3 != null) {
inputRootBinding.inputRoot.setBackground(d3);
} else {
// 避免因为键盘整体透明而造成的异常
inputRootBinding.inputRoot.setBackgroundColor(Color.WHITE);
}

tabView.reset(this);
tabView.reset(self);
}

public void resetKeyboard() {
Expand All @@ -543,6 +548,7 @@ public void resetCandidate() {

/** 重置鍵盤、候選條、狀態欄等 !!注意,如果其中調用Rime.setOption,切換方案會卡住 */
private void reset() {
if (inputRootBinding == null) return;
getImeConfig().reset();
loadConfig();
getImeConfig().initCurrentColors();
Expand Down Expand Up @@ -1302,7 +1308,8 @@ private String getActiveText(int type) {

/** 更新Rime的中西文狀態、編輯區文本 */
public void updateComposing() {
final @Nullable InputConnection ic = getCurrentInputConnection();
final InputConnection ic = getCurrentInputConnection();
if (ic == null) return;
if (inlinePreedit != InlineModeType.INLINE_NONE) { // 嵌入模式
String s = "";
switch (inlinePreedit) {
Expand Down

0 comments on commit 8fe8c71

Please sign in to comment.