fix build and small style adjustments after adding autofill

This commit is contained in:
Helium314 2023-12-29 10:03:22 +01:00
parent ab183c53d7
commit fcff8c9098
2 changed files with 11 additions and 16 deletions

View file

@ -40,7 +40,6 @@ import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.inputmethod.InlineSuggestionsResponse;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.HorizontalScrollView;
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
@ -1360,7 +1359,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if(!mSettings.getCurrent().isSuggestionsEnabledPerUserSettings()){
return null;
}
return InlineAutofillUtils.createInlineSuggestionRequest(mDisplayContext);
}
@ -1368,20 +1366,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@RequiresApi(api = Build.VERSION_CODES.R)
public boolean onInlineSuggestionsResponse(InlineSuggestionsResponse response) {
Log.d(TAG,"onInlineSuggestionsResponse called");
final List<InlineSuggestion> inlineSuggestions = response.getInlineSuggestions();
if (inlineSuggestions.isEmpty()) {
return false;
}
HorizontalScrollView view = InlineAutofillUtils.createView(inlineSuggestions, mDisplayContext);
// Delay required to show properly
final View inlineSuggestionView = InlineAutofillUtils.createView(inlineSuggestions, mDisplayContext);
// "normal" suggestions might be determined in parallel when processing MSG_UPDATE_SUGGESTION_STRIP
// so we add a delay to make sure inline suggestions are set only after normal suggestions
new Handler().postDelayed(() -> {
mSuggestionStripView.clear();
mSuggestionStripView.hideKeys();
mSuggestionStripView.addSuggestionView(view);
mSuggestionStripView.hideToolbarKeys();
mSuggestionStripView.addSuggestionView(inlineSuggestionView);
}, 200);
return true;

View file

@ -268,8 +268,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mSuggestionsStrip.addView(view);
}
public void hideKeys() {
mToolbarKey.setVisibility(GONE);
public void hideToolbarKeys() {
mToolbarExpandKey.setVisibility(GONE);
mPinnedKeys.setVisibility(GONE);
}
@ -280,7 +280,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
@SuppressLint("ClickableViewAccessibility") // why would "null" need to call View#performClick?
public void clear() {
mSuggestionsStrip.removeAllViews();
removeAllDebugInfoViews();
if (DEBUG_SUGGESTIONS)
removeAllDebugInfoViews();
if (mToolbarContainer.getVisibility() != VISIBLE)
mStripVisibilityGroup.showSuggestionsStrip();
dismissMoreSuggestionsPanel();
@ -288,10 +289,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
word.setOnTouchListener(null);
}
if (mToolbarKey.getVisibility() != VISIBLE || mPinnedKeys.getVisibility() != VISIBLE){
mToolbarKey.setVisibility(VISIBLE);
mPinnedKeys.setVisibility(VISIBLE);
}
mToolbarExpandKey.setVisibility(VISIBLE);
mPinnedKeys.setVisibility(VISIBLE);
}
private void removeAllDebugInfoViews() {