Skip to content

Commit 1089ddb

Browse files
committedSep 20, 2020
Dont update #f, #r if flagNoPersonalizedLearning
If imeOptions includes "flagNoPersonalizedLearning" (aka incognito mode) then do not add utterances to the #f and #r tables, even when they are active. + Small changes
1 parent c5489f1 commit 1089ddb

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed
 

‎app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies {
1212
implementation 'androidx.recyclerview:recyclerview:1.1.0'
1313
//implementation 'androidx.activity:activity:1.2.0-alpha06'
1414
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
15-
implementation 'com.google.android.material:material:1.2.0'
15+
implementation 'com.google.android.material:material:1.2.1'
1616
}
1717

1818
android {
@@ -26,8 +26,8 @@ android {
2626
applicationId 'ee.ioc.phon.android.speak'
2727
minSdkVersion 16
2828
targetSdkVersion 30
29-
versionCode 1738
30-
versionName '1.7.38'
29+
versionCode 1740
30+
versionName '1.7.40'
3131
vectorDrawables.useSupportLibrary = true
3232
// Keep only en and et resources
3333
resConfigs "en", "et"

‎app/src/main/AndroidManifest.xml

+8-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,16 @@
8282

8383
<!-- <uses-feature android:name="android.hardware.type.watch" /> -->
8484

85+
<!-- TODO: review -->
86+
8587
<queries>
8688
<intent>
8789
<!-- Packages that provide speech recognition services -->
88-
<action android:name="android.speech.RecognitionService" />
90+
<action android:name="android.intent.action.TTS_SERVICE" />
91+
</intent>
92+
<intent>
93+
<!-- Packages that provide TTS services -->
94+
<action android:name="android.intent.action.TTS_SERVICE" />
8995
</intent>
9096
</queries>
9197

@@ -483,4 +489,4 @@ Also, failed to set the launchMode from the resource, INSTALL_PARSE_FAILED_UNEXP
483489
android:permission="android.permission.RECORD_AUDIO" />
484490
</application>
485491

486-
</manifest>
492+
</manifest>

‎app/src/main/java/ee/ioc/phon/android/speak/service/SpeechInputMethodService.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class SpeechInputMethodService extends InputMethodService {
5353
private static final String REWRITES_NAME_FREQUENT = "#f";
5454
private static final String REWRITES_NAME_CLIP = "#c";
5555

56+
private boolean mFlagPersonalizedLearning = true;
5657
private InputMethodManager mInputMethodManager;
5758
private SpeechInputView mInputView;
5859
private CommandEditor mCommandEditor;
@@ -123,6 +124,10 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
123124
super.onStartInput(attribute, restarting);
124125
String type = "UNKNOWN";
125126

127+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
128+
mFlagPersonalizedLearning = (attribute.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
129+
}
130+
126131
switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
127132
case InputType.TYPE_CLASS_NUMBER:
128133
type = "NUMBER";
@@ -163,7 +168,7 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
163168

164169
default:
165170
}
166-
Log.i("onStartInput: " + type + ", " + attribute.inputType + ", " + attribute.imeOptions + ", " + restarting);
171+
Log.i("onStartInput: " + type + ", " + attribute.inputType + ", " + attribute.imeOptions + ", " + restarting + ", learning: " + mFlagPersonalizedLearning);
167172
}
168173

169174
/**
@@ -352,7 +357,7 @@ private void commitResults(List<String> results) {
352357
if (editorResult != null && mInputView != null && editorResult.isCommand()) {
353358
mInputView.showMessage(editorResult.getRewrite().ppCommand(), editorResult.isSuccess());
354359
}
355-
if (editorResult != null) {
360+
if (editorResult != null && mFlagPersonalizedLearning) {
356361
String rewritesRec = getRewrites(REWRITES_NAME_RECENT);
357362
if (rewritesRec != null) {
358363
UtteranceRewriter ur = mRuleManager.addRecent(editorResult, rewritesRec);

‎app/src/main/java/ee/ioc/phon/android/speak/view/SpeechInputView.java

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public void setListener(final SpeechInputViewListener listener, EditorInfo edito
166166
mApp = new ComponentName(editorInfo.packageName, editorInfo.packageName);
167167
}
168168
if (mBImeAction != null && editorInfo != null) {
169+
// TODO: test
169170
boolean overrideEnter = (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0;
170171
boolean useEnter = !overrideEnter;
171172
final int imeAction = editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;

‎app/src/main/res/layout/encoder_demo.xml

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
android:gravity="center"
1414
android:orientation="vertical">
1515

16+
<EditText
17+
android:layout_width="fill_parent"
18+
android:layout_height="wrap_content"
19+
android:hint="flagNoPersonalizedLearning"
20+
android:imeActionLabel="NEXT"
21+
android:imeOptions="flagNoPersonalizedLearning|actionNext"
22+
android:inputType="text" />
23+
1624
<EditText
1725
android:layout_width="fill_parent"
1826
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)
Failed to load comments.