Merge "Change visibility to avoid synthetic accessor method"
This commit is contained in:
commit
eee2a066d8
5 changed files with 99 additions and 99 deletions
|
@ -51,6 +51,7 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
private Object mUpdatingLock = new Object();
|
private Object mUpdatingLock = new Object();
|
||||||
|
|
||||||
private static class Node {
|
private static class Node {
|
||||||
|
Node() {}
|
||||||
char mCode;
|
char mCode;
|
||||||
int mFrequency;
|
int mFrequency;
|
||||||
boolean mTerminal;
|
boolean mTerminal;
|
||||||
|
@ -547,6 +548,7 @@ public class ExpandableDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LoadDictionaryTask extends Thread {
|
private class LoadDictionaryTask extends Thread {
|
||||||
|
LoadDictionaryTask() {}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
loadDictionaryAsync();
|
loadDictionaryAsync();
|
||||||
|
|
|
@ -468,6 +468,91 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
setLayoutWeight(
|
setLayoutWeight(
|
||||||
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
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());
|
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() {
|
public boolean isShowingAddToDictionaryHint() {
|
||||||
return mSuggestionsStrip.getChildCount() > 0
|
return mSuggestionsStrip.getChildCount() > 0
|
||||||
|
|
|
@ -18,13 +18,10 @@ package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import android.content.ContentProviderClient;
|
import android.content.ContentProviderClient;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.provider.UserDictionary.Words;
|
import android.provider.UserDictionary.Words;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
|
|
@ -543,13 +543,13 @@ public class Utils {
|
||||||
final String currentDateTimeString =
|
final String currentDateTimeString =
|
||||||
new SimpleDateFormat("yyyyMMdd-HHmmssZ").format(date);
|
new SimpleDateFormat("yyyyMMdd-HHmmssZ").format(date);
|
||||||
if (mFile == null) {
|
if (mFile == null) {
|
||||||
Log.w(TAG, "No internal log file found.");
|
Log.w(USABILITY_TAG, "No internal log file found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mIms.checkCallingOrSelfPermission(
|
if (mIms.checkCallingOrSelfPermission(
|
||||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= 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;
|
return;
|
||||||
}
|
}
|
||||||
mWriter.flush();
|
mWriter.flush();
|
||||||
|
@ -563,20 +563,20 @@ public class Utils {
|
||||||
src.close();
|
src.close();
|
||||||
dest.close();
|
dest.close();
|
||||||
} catch (FileNotFoundException e1) {
|
} catch (FileNotFoundException e1) {
|
||||||
Log.w(TAG, e1);
|
Log.w(USABILITY_TAG, e1);
|
||||||
return;
|
return;
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
Log.w(TAG, e2);
|
Log.w(USABILITY_TAG, e2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (destFile == null || !destFile.exists()) {
|
if (destFile == null || !destFile.exists()) {
|
||||||
Log.w(TAG, "Dest file doesn't exist.");
|
Log.w(USABILITY_TAG, "Dest file doesn't exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Intent intent = new Intent(Intent.ACTION_SEND);
|
final Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
if (LatinImeLogger.sDBG) {
|
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.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + destPath));
|
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + destPath));
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SpellCheckerProximityInfo {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Latin {
|
private static class Latin {
|
||||||
// This is a map from the code point to the index in the PROXIMITY array.
|
// 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
|
// 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
|
// 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 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
|
// 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.
|
// 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,
|
'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,
|
'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,
|
'e', 'w', 's', 'd', 'f', 'r', 'a', 'i', 'o', 'u', NUL, NUL, NUL, NUL, NUL, NUL,
|
||||||
|
@ -101,14 +101,14 @@ public class SpellCheckerProximityInfo {
|
||||||
static {
|
static {
|
||||||
buildProximityIndices(PROXIMITY, INDICES);
|
buildProximityIndices(PROXIMITY, INDICES);
|
||||||
}
|
}
|
||||||
private static int getIndexOf(int characterCode) {
|
static int getIndexOf(int characterCode) {
|
||||||
return computeIndex(characterCode, INDICES);
|
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 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
|
// TODO: This table is solely based on the keyboard layout. Consult with Russian
|
||||||
// speakers on commonly misspelled words/letters.
|
// speakers on commonly misspelled words/letters.
|
||||||
'й', 'ц', 'ф', 'ы', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
|
'й', 'ц', 'ф', 'ы', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
|
||||||
|
@ -150,7 +150,7 @@ public class SpellCheckerProximityInfo {
|
||||||
static {
|
static {
|
||||||
buildProximityIndices(PROXIMITY, INDICES);
|
buildProximityIndices(PROXIMITY, INDICES);
|
||||||
}
|
}
|
||||||
private static int getIndexOf(int characterCode) {
|
static int getIndexOf(int characterCode) {
|
||||||
return computeIndex(characterCode, INDICES);
|
return computeIndex(characterCode, INDICES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue