am eee2a066: Merge "Change visibility to avoid synthetic accessor method"
* commit 'eee2a066d8bcde65a128abb0d0618a280e623688': Change visibility to avoid synthetic accessor methodmain
commit
c71aa81fbd
|
@ -51,6 +51,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
private Object mUpdatingLock = new Object();
|
||||
|
||||
private static class Node {
|
||||
Node() {}
|
||||
char mCode;
|
||||
int mFrequency;
|
||||
boolean mTerminal;
|
||||
|
@ -547,6 +548,7 @@ public class ExpandableDictionary extends Dictionary {
|
|||
}
|
||||
|
||||
private class LoadDictionaryTask extends Thread {
|
||||
LoadDictionaryTask() {}
|
||||
@Override
|
||||
public void run() {
|
||||
loadDictionaryAsync();
|
||||
|
|
|
@ -468,6 +468,91 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
|||
setLayoutWeight(
|
||||
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
|
||||
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
||||
if (DBG && pos < suggestions.size()) {
|
||||
final SuggestedWordInfo wordInfo = suggestions.getInfo(pos);
|
||||
if (wordInfo != null) {
|
||||
final CharSequence debugInfo = wordInfo.getDebugString();
|
||||
if (!TextUtils.isEmpty(debugInfo)) {
|
||||
return debugInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setLayoutWeight(View v, float weight, int height) {
|
||||
final ViewGroup.LayoutParams lp = v.getLayoutParams();
|
||||
if (lp instanceof LinearLayout.LayoutParams) {
|
||||
final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
|
||||
llp.weight = weight;
|
||||
llp.width = 0;
|
||||
llp.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
private static float getTextScaleX(CharSequence text, int maxWidth, TextPaint paint) {
|
||||
paint.setTextScaleX(1.0f);
|
||||
final int width = getTextWidth(text, paint);
|
||||
if (width <= maxWidth) {
|
||||
return 1.0f;
|
||||
}
|
||||
return maxWidth / (float)width;
|
||||
}
|
||||
|
||||
private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
|
||||
TextPaint paint) {
|
||||
if (text == null) return null;
|
||||
paint.setTextScaleX(1.0f);
|
||||
final int width = getTextWidth(text, paint);
|
||||
if (width <= maxWidth) {
|
||||
return text;
|
||||
}
|
||||
final float scaleX = maxWidth / (float)width;
|
||||
if (scaleX >= MIN_TEXT_XSCALE) {
|
||||
paint.setTextScaleX(scaleX);
|
||||
return text;
|
||||
}
|
||||
|
||||
// Note that TextUtils.ellipsize() use text-x-scale as 1.0 if ellipsize is needed. To
|
||||
// get squeezed and ellipsized text, passes enlarged width (maxWidth / MIN_TEXT_XSCALE).
|
||||
final CharSequence ellipsized = TextUtils.ellipsize(
|
||||
text, paint, maxWidth / MIN_TEXT_XSCALE, TextUtils.TruncateAt.MIDDLE);
|
||||
paint.setTextScaleX(MIN_TEXT_XSCALE);
|
||||
return ellipsized;
|
||||
}
|
||||
|
||||
private static int getTextWidth(CharSequence text, TextPaint paint) {
|
||||
if (TextUtils.isEmpty(text)) return 0;
|
||||
final Typeface savedTypeface = paint.getTypeface();
|
||||
paint.setTypeface(getTextTypeface(text));
|
||||
final int len = text.length();
|
||||
final float[] widths = new float[len];
|
||||
final int count = paint.getTextWidths(text, 0, len, widths);
|
||||
int width = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
width += Math.round(widths[i] + 0.5f);
|
||||
}
|
||||
paint.setTypeface(savedTypeface);
|
||||
return width;
|
||||
}
|
||||
|
||||
private static Typeface getTextTypeface(CharSequence text) {
|
||||
if (!(text instanceof SpannableString))
|
||||
return Typeface.DEFAULT;
|
||||
|
||||
final SpannableString ss = (SpannableString)text;
|
||||
final StyleSpan[] styles = ss.getSpans(0, text.length(), StyleSpan.class);
|
||||
if (styles.length == 0)
|
||||
return Typeface.DEFAULT;
|
||||
|
||||
switch (styles[0].getStyle()) {
|
||||
case Typeface.BOLD: return Typeface.DEFAULT_BOLD;
|
||||
// TODO: BOLD_ITALIC, ITALIC case?
|
||||
default: return Typeface.DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -554,90 +639,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
|||
mParams.layout(mSuggestions, mSuggestionsStrip, this, getWidth());
|
||||
}
|
||||
|
||||
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
||||
if (DBG && pos < suggestions.size()) {
|
||||
final SuggestedWordInfo wordInfo = suggestions.getInfo(pos);
|
||||
if (wordInfo != null) {
|
||||
final CharSequence debugInfo = wordInfo.getDebugString();
|
||||
if (!TextUtils.isEmpty(debugInfo)) {
|
||||
return debugInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setLayoutWeight(View v, float weight, int height) {
|
||||
final ViewGroup.LayoutParams lp = v.getLayoutParams();
|
||||
if (lp instanceof LinearLayout.LayoutParams) {
|
||||
final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
|
||||
llp.weight = weight;
|
||||
llp.width = 0;
|
||||
llp.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
private static float getTextScaleX(CharSequence text, int maxWidth, TextPaint paint) {
|
||||
paint.setTextScaleX(1.0f);
|
||||
final int width = getTextWidth(text, paint);
|
||||
if (width <= maxWidth) {
|
||||
return 1.0f;
|
||||
}
|
||||
return maxWidth / (float)width;
|
||||
}
|
||||
|
||||
private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
|
||||
TextPaint paint) {
|
||||
if (text == null) return null;
|
||||
paint.setTextScaleX(1.0f);
|
||||
final int width = getTextWidth(text, paint);
|
||||
if (width <= maxWidth) {
|
||||
return text;
|
||||
}
|
||||
final float scaleX = maxWidth / (float)width;
|
||||
if (scaleX >= MIN_TEXT_XSCALE) {
|
||||
paint.setTextScaleX(scaleX);
|
||||
return text;
|
||||
}
|
||||
|
||||
// Note that TextUtils.ellipsize() use text-x-scale as 1.0 if ellipsize is needed. To get
|
||||
// squeezed and ellipsized text, passes enlarged width (maxWidth / MIN_TEXT_XSCALE).
|
||||
final CharSequence ellipsized = TextUtils.ellipsize(
|
||||
text, paint, maxWidth / MIN_TEXT_XSCALE, TextUtils.TruncateAt.MIDDLE);
|
||||
paint.setTextScaleX(MIN_TEXT_XSCALE);
|
||||
return ellipsized;
|
||||
}
|
||||
|
||||
private static int getTextWidth(CharSequence text, TextPaint paint) {
|
||||
if (TextUtils.isEmpty(text)) return 0;
|
||||
final Typeface savedTypeface = paint.getTypeface();
|
||||
paint.setTypeface(getTextTypeface(text));
|
||||
final int len = text.length();
|
||||
final float[] widths = new float[len];
|
||||
final int count = paint.getTextWidths(text, 0, len, widths);
|
||||
int width = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
width += Math.round(widths[i] + 0.5f);
|
||||
}
|
||||
paint.setTypeface(savedTypeface);
|
||||
return width;
|
||||
}
|
||||
|
||||
private static Typeface getTextTypeface(CharSequence text) {
|
||||
if (!(text instanceof SpannableString))
|
||||
return Typeface.DEFAULT;
|
||||
|
||||
final SpannableString ss = (SpannableString)text;
|
||||
final StyleSpan[] styles = ss.getSpans(0, text.length(), StyleSpan.class);
|
||||
if (styles.length == 0)
|
||||
return Typeface.DEFAULT;
|
||||
|
||||
switch (styles[0].getStyle()) {
|
||||
case Typeface.BOLD: return Typeface.DEFAULT_BOLD;
|
||||
// TODO: BOLD_ITALIC, ITALIC case?
|
||||
default: return Typeface.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isShowingAddToDictionaryHint() {
|
||||
return mSuggestionsStrip.getChildCount() > 0
|
||||
|
|
|
@ -18,13 +18,10 @@ package com.android.inputmethod.latin;
|
|||
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.UserDictionary.Words;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
|
|
@ -543,13 +543,13 @@ public class Utils {
|
|||
final String currentDateTimeString =
|
||||
new SimpleDateFormat("yyyyMMdd-HHmmssZ").format(date);
|
||||
if (mFile == null) {
|
||||
Log.w(TAG, "No internal log file found.");
|
||||
Log.w(USABILITY_TAG, "No internal log file found.");
|
||||
return;
|
||||
}
|
||||
if (mIms.checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Log.w(TAG, "Doesn't have the permission WRITE_EXTERNAL_STORAGE");
|
||||
Log.w(USABILITY_TAG, "Doesn't have the permission WRITE_EXTERNAL_STORAGE");
|
||||
return;
|
||||
}
|
||||
mWriter.flush();
|
||||
|
@ -563,20 +563,20 @@ public class Utils {
|
|||
src.close();
|
||||
dest.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
Log.w(TAG, e1);
|
||||
Log.w(USABILITY_TAG, e1);
|
||||
return;
|
||||
} catch (IOException e2) {
|
||||
Log.w(TAG, e2);
|
||||
Log.w(USABILITY_TAG, e2);
|
||||
return;
|
||||
}
|
||||
if (destFile == null || !destFile.exists()) {
|
||||
Log.w(TAG, "Dest file doesn't exist.");
|
||||
Log.w(USABILITY_TAG, "Dest file doesn't exist.");
|
||||
return;
|
||||
}
|
||||
final Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (LatinImeLogger.sDBG) {
|
||||
Log.d(TAG, "Destination file URI is " + destFile.toURI());
|
||||
Log.d(USABILITY_TAG, "Destination file URI is " + destFile.toURI());
|
||||
}
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + destPath));
|
||||
|
|
|
@ -43,7 +43,7 @@ public class SpellCheckerProximityInfo {
|
|||
return result;
|
||||
}
|
||||
|
||||
static class Latin {
|
||||
private static class Latin {
|
||||
// This is a map from the code point to the index in the PROXIMITY array.
|
||||
// At the time the native code to read the binary dictionary needs the proximity info be
|
||||
// passed as a flat array spaced by MAX_PROXIMITY_CHARS_SIZE columns, one for each input
|
||||
|
@ -62,7 +62,7 @@ public class SpellCheckerProximityInfo {
|
|||
// to spell check has been entered with one of the keyboards above. Also, specifically
|
||||
// to English, many spelling errors consist of the last vowel of the word being wrong
|
||||
// because in English vowels tend to merge with each other in pronunciation.
|
||||
final private static int[] PROXIMITY = {
|
||||
final static int[] PROXIMITY = {
|
||||
'q', 'w', 's', 'a', 'z', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
|
||||
'w', 'q', 'a', 's', 'd', 'e', 'x', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
|
||||
'e', 'w', 's', 'd', 'f', 'r', 'a', 'i', 'o', 'u', NUL, NUL, NUL, NUL, NUL, NUL,
|
||||
|
@ -101,14 +101,14 @@ public class SpellCheckerProximityInfo {
|
|||
static {
|
||||
buildProximityIndices(PROXIMITY, INDICES);
|
||||
}
|
||||
private static int getIndexOf(int characterCode) {
|
||||
static int getIndexOf(int characterCode) {
|
||||
return computeIndex(characterCode, INDICES);
|
||||
}
|
||||
}
|
||||
|
||||
static class Cyrillic {
|
||||
private static class Cyrillic {
|
||||
final private static TreeMap<Integer, Integer> INDICES = new TreeMap<Integer, Integer>();
|
||||
final private static int[] PROXIMITY = {
|
||||
final static int[] PROXIMITY = {
|
||||
// TODO: This table is solely based on the keyboard layout. Consult with Russian
|
||||
// speakers on commonly misspelled words/letters.
|
||||
'й', 'ц', 'ф', 'ы', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
|
||||
|
@ -150,7 +150,7 @@ public class SpellCheckerProximityInfo {
|
|||
static {
|
||||
buildProximityIndices(PROXIMITY, INDICES);
|
||||
}
|
||||
private static int getIndexOf(int characterCode) {
|
||||
static int getIndexOf(int characterCode) {
|
||||
return computeIndex(characterCode, INDICES);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue