mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-08 07:37:41 +00:00
Clipboard suggestions (#647)
This commit is contained in:
parent
21124a5a45
commit
bdab98c2c9
17 changed files with 213 additions and 18 deletions
|
@ -1029,12 +1029,11 @@ public class LatinIME extends InputMethodService implements
|
|||
// Space state must be updated before calling updateShiftState
|
||||
switcher.requestUpdatingShiftState(getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||
}
|
||||
// This will set the punctuation suggestions if next word suggestion is off;
|
||||
// otherwise it will clear the suggestion strip.
|
||||
// Set neutral suggestions and show the toolbar if the "Auto show toolbar" setting is enabled.
|
||||
if (!mHandler.hasPendingResumeSuggestions()) {
|
||||
mHandler.cancelUpdateSuggestionStrip();
|
||||
setNeutralSuggestionStrip();
|
||||
if (hasSuggestionStripView() && currentSettingsValues.mAutoShowToolbar) {
|
||||
if (hasSuggestionStripView() && currentSettingsValues.mAutoShowToolbar && !tryShowClipboardSuggestion()) {
|
||||
mSuggestionStripView.setToolbarVisibility(true);
|
||||
}
|
||||
}
|
||||
|
@ -1330,7 +1329,7 @@ public class LatinIME extends InputMethodService implements
|
|||
// Without this function the inline autofill suggestions will not be visible
|
||||
mHandler.cancelResumeSuggestions();
|
||||
|
||||
mSuggestionStripView.setInlineSuggestionsView(inlineSuggestionView);
|
||||
mSuggestionStripView.setExternalSuggestionView(inlineSuggestionView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1652,13 +1651,33 @@ public class LatinIME extends InputMethodService implements
|
|||
updateStateAfterInputTransaction(completeInputTransaction);
|
||||
}
|
||||
|
||||
// This will show either an empty suggestion strip (if prediction is enabled) or
|
||||
// punctuation suggestions (if it's disabled).
|
||||
// The toolbar will be shown automatically if the relevant setting is enabled
|
||||
/**
|
||||
* Checks if a recent clipboard suggestion is available. If available, it is set in suggestion strip.
|
||||
* returns whether a clipboard suggestion has been set.
|
||||
*/
|
||||
public boolean tryShowClipboardSuggestion() {
|
||||
final View clipboardView = mClipboardHistoryManager.getClipboardSuggestionView(getCurrentInputEditorInfo(), mSuggestionStripView);
|
||||
if (clipboardView != null && hasSuggestionStripView()) {
|
||||
mSuggestionStripView.setExternalSuggestionView(clipboardView);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// This will first try showing a clipboard suggestion. On success, the toolbar will be hidden
|
||||
// if the "Auto hide toolbar" is enabled. Otherwise, an empty suggestion strip (if prediction
|
||||
// is enabled) or punctuation suggestions (if it's disabled) will be set.
|
||||
// Then, the toolbar will be shown automatically if the relevant setting is enabled
|
||||
// and there is a selection of text or it's the start of a line.
|
||||
@Override
|
||||
public void setNeutralSuggestionStrip() {
|
||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||
if (tryShowClipboardSuggestion()) {
|
||||
// clipboard suggestion has been set
|
||||
if (hasSuggestionStripView() && currentSettings.mAutoHideToolbar)
|
||||
mSuggestionStripView.setToolbarVisibility(false);
|
||||
return;
|
||||
}
|
||||
final SuggestedWords neutralSuggestions = currentSettings.mBigramPredictionEnabled
|
||||
? SuggestedWords.getEmptyInstance()
|
||||
: currentSettings.mSpacingAndPunctuations.mSuggestPuncList;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue