Skip to content

Commit

Permalink
feat: privacy protection for draft
Browse files Browse the repository at this point in the history
  • Loading branch information
tumuyan authored and Bambooin committed Jan 11, 2022
1 parent 3526ae3 commit 4cd4982
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
49 changes: 46 additions & 3 deletions app/src/main/java/com/osfans/trime/ime/core/Trime.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.InputType;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
Expand Down Expand Up @@ -96,6 +97,7 @@
public class Trime extends LifecycleInputMethodService {
private static Trime self = null;
private LiquidKeyboard liquidKeyboard;
private boolean normalTextEditor;

@NonNull
private Preferences getPrefs() {
Expand Down Expand Up @@ -697,13 +699,54 @@ public void onStartInputView(EditorInfo attribute, boolean restarting) {
bindKeyboardToInputView();
if (!restarting) setNavBarColor();
setCandidatesViewShown(!Rime.isEmpty()); // 軟鍵盤出現時顯示候選欄
activeEditorInstance.cacheDraft();
addDraft();

switch (attribute.inputType & InputType.TYPE_MASK_VARIATION) {
case InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
case InputType.TYPE_TEXT_VARIATION_PASSWORD:
case InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD:
case InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
case InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD:
Timber.i(
"EditorInfo: private;"
+ " packageName"
+ attribute.packageName
+ "; fieldName"
+ attribute.fieldName
+ "; actionLabel"
+ attribute.actionLabel
+ "; inputType"
+ attribute.inputType
+ "; &v "
+ (attribute.inputType & InputType.TYPE_MASK_VARIATION)
+ "; &c "
+ (attribute.inputType & InputType.TYPE_MASK_CLASS));
normalTextEditor = false;
break;

default:
Timber.i(
"EditorInfo: normal;"
+ " packageName"
+ attribute.packageName
+ "; fieldName"
+ attribute.fieldName
+ "; actionLabel"
+ attribute.actionLabel
+ "; inputType"
+ attribute.inputType
+ "; &v "
+ (attribute.inputType & InputType.TYPE_MASK_VARIATION)
+ "; &c "
+ (attribute.inputType & InputType.TYPE_MASK_CLASS));
normalTextEditor = true;
activeEditorInstance.cacheDraft();
addDraft();
}
}

@Override
public void onFinishInputView(boolean finishingInput) {
addDraft();
if (normalTextEditor) addDraft();
super.onFinishInputView(finishingInput);
// Dismiss any pop-ups when the input-view is being finished and hidden.
mainKeyboardView.closing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.Runnable
import kotlinx.coroutines.cancel
import timber.log.Timber
import java.util.Locale

/**
Expand Down Expand Up @@ -196,6 +197,12 @@ class TextInputManager private constructor() :
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS,
InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD -> {
Timber.i(
"EditorInfo: " +
" inputAttrsRaw" + inputAttrsRaw +
"; InputType" + (inputAttrsRaw and InputType.TYPE_MASK_VARIATION)
)

tempAsciiMode = true
".ascii"
}
Expand Down

0 comments on commit 4cd4982

Please sign in to comment.