Skip to content

Commit

Permalink
feat: display a loading screen as keyboard during deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
goofyz committed Dec 30, 2023
1 parent a6765b7 commit 31f4e1d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 14 deletions.
39 changes: 25 additions & 14 deletions app/src/main/java/com/osfans/trime/ime/core/Trime.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.osfans.trime.data.sound.SoundThemeManager;
import com.osfans.trime.data.theme.Theme;
import com.osfans.trime.databinding.CompositionRootBinding;
import com.osfans.trime.databinding.InputLoadingBinding;
import com.osfans.trime.databinding.InputRootBinding;
import com.osfans.trime.ime.broadcast.IntentReceiver;
import com.osfans.trime.ime.enums.Keycode;
Expand Down Expand Up @@ -722,6 +723,10 @@ public void onUpdateSelection(
}
// Update the caps-lock status for the current cursor position.
dispatchCapsStateToInputView();

Timber.d(
"OnUpdateSelection: old: %d, %d, new: %d, %d, candidate: %d, %d",
oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart, candidatesEnd);
}

@Override
Expand Down Expand Up @@ -776,7 +781,7 @@ public View onCreateInputView() {
});
Timber.i("onCreateInputView() finish");

return null;
return InputLoadingBinding.inflate(LayoutInflater.from(this)).getRoot();
}

public void setShowComment(boolean show_comment) {
Expand Down Expand Up @@ -893,21 +898,24 @@ public void onStartInputView(EditorInfo attribute, boolean restarting) {

@Override
public void onFinishInputView(boolean finishingInput) {
if (normalTextEditor) {
DraftHelper.INSTANCE.onInputEventChanged();
}
super.onFinishInputView(finishingInput);
// Dismiss any pop-ups when the input-view is being finished and hidden.
mainKeyboardView.closing();
performEscape();
if (inputFeedbackManager != null) {
inputFeedbackManager.releaseSoundPool();
}
try {
hideCompositionView();
} catch (Exception e) {
Timber.e(e, "Failed to show the PopupWindow.");
if (RimeWrapper.INSTANCE.isReady()) {
if (normalTextEditor) {
DraftHelper.INSTANCE.onInputEventChanged();
}
try {
// Dismiss any pop-ups when the input-view is being finished and hidden.
mainKeyboardView.closing();
performEscape();
if (inputFeedbackManager != null) {
inputFeedbackManager.releaseSoundPool();
}
hideCompositionView();
} catch (Exception e) {
Timber.e(e, "Failed to show the PopupWindow.");
}
}
Timber.d("OnFinishInputView");
}

@Override
Expand Down Expand Up @@ -1293,13 +1301,16 @@ public boolean onEvaluateFullscreenMode() {
} else {
switch (getPrefs().getKeyboard().getFullscreenMode()) {
case AUTO_SHOW:
Timber.d("FullScreen: Auto");
final EditorInfo ei = getCurrentInputEditorInfo();
if (ei != null && (ei.imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0) {
return false;
}
case ALWAYS_SHOW:
Timber.d("FullScreen: Always");
return true;
case NEVER_SHOW:
Timber.d("FullScreen: Never");
return false;
}
}
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/res/layout/input_loading.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
>
<TextView
android:id="@+id/deploying"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/deploy_progress"
android:textColor="@color/colorAccent"
android:textSize="24sp"
android:textAlignment="center"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="148dp"
android:layout_height="24dp"
android:layout_marginBottom="24dp"
android:indeterminate="true"
style="?android:attr/progressBarStyleHorizontal"
app:layout_constraintTop_toBottomOf="@id/deploying"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 31f4e1d

Please sign in to comment.