Merge "Clean up some translation todos."
This commit is contained in:
committed by
Android (Google) Code Review
commit
fe29c8481c
32
core/java/android/view/translation/Helper.java
Normal file
32
core/java/android/view/translation/Helper.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view.translation;
|
||||
|
||||
/** @hide */
|
||||
public class Helper {
|
||||
|
||||
// Debug-level flags are defined when service is bound.
|
||||
public static boolean sDebug = false;
|
||||
public static boolean sVerbose = false;
|
||||
|
||||
// TODO: Use a device config value.
|
||||
public static final int ANIMATION_DURATION_MILLIS = 250;
|
||||
|
||||
private Helper() {
|
||||
throw new UnsupportedOperationException("contains static members only");
|
||||
}
|
||||
}
|
||||
@@ -53,9 +53,6 @@ public class Translator {
|
||||
|
||||
private static final String TAG = "Translator";
|
||||
|
||||
// TODO: make this configurable and cross the Translation component
|
||||
private static boolean sDEBUG = false;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
private int mId;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.view.translation;
|
||||
|
||||
import static android.view.translation.Helper.ANIMATION_DURATION_MILLIS;
|
||||
import static android.view.translation.UiTranslationManager.STATE_UI_TRANSLATION_FINISHED;
|
||||
import static android.view.translation.UiTranslationManager.STATE_UI_TRANSLATION_PAUSED;
|
||||
import static android.view.translation.UiTranslationManager.STATE_UI_TRANSLATION_RESUMED;
|
||||
@@ -26,6 +27,7 @@ import android.annotation.WorkerThread;
|
||||
import android.app.Activity;
|
||||
import android.app.assist.ActivityId;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Process;
|
||||
@@ -465,9 +467,6 @@ public class UiTranslationController {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use a device config value.
|
||||
private static final int ANIMATION_DURATION_MILLIS = 250;
|
||||
|
||||
/**
|
||||
* Creates a Translator for the given source and target translation specs and start the ui
|
||||
* translation when the Translator is created successfully.
|
||||
@@ -724,7 +723,21 @@ public class UiTranslationController {
|
||||
msg.append("text=").append(value.getText() == null
|
||||
? "null"
|
||||
: "string[" + value.getText().length() + "], ");
|
||||
//TODO: append dictionary results.
|
||||
final Bundle definitions =
|
||||
(Bundle) value.getExtras().get(TranslationResponseValue.EXTRA_DEFINITIONS);
|
||||
if (definitions != null) {
|
||||
msg.append("definitions={");
|
||||
for (String partOfSpeech : definitions.keySet()) {
|
||||
msg.append(partOfSpeech).append(":[");
|
||||
for (CharSequence definition : definitions.getCharSequenceArray(partOfSpeech)) {
|
||||
msg.append(definition == null
|
||||
? "null, "
|
||||
: "string[" + definition.length() + "], ");
|
||||
}
|
||||
msg.append("], ");
|
||||
}
|
||||
msg.append("}");
|
||||
}
|
||||
msg.append("transliteration=").append(value.getTransliteration() == null
|
||||
? "null"
|
||||
: "string[" + value.getTransliteration().length() + "]}, ");
|
||||
|
||||
Reference in New Issue
Block a user