Skip to content
Snippets Groups Projects
Commit 3eede315 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Move MoreKeySpecParser.getResourceId to Utils"

parents 86641ef6 07185904
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import android.util.Log;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Utils;
import java.util.ArrayList;
......@@ -150,8 +151,9 @@ public class MoreKeySpecParser {
if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) {
throw new MoreKeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec);
}
final int resId = getResourceId(res,
moreKeySpec.substring(end + LABEL_END.length() + PREFIX_AT.length()));
final int resId = Utils.getResourceId(res,
moreKeySpec.substring(end + LABEL_END.length() + PREFIX_AT.length()),
R.string.english_ime_name);
final int code = res.getInteger(resId);
return code;
}
......@@ -180,15 +182,6 @@ public class MoreKeySpecParser {
return KeyboardIconsSet.ICON_UNDEFINED;
}
private static int getResourceId(Resources res, String name) {
String packageName = res.getResourcePackageName(R.string.english_ime_name);
int resId = res.getIdentifier(name, null, packageName);
if (resId == 0) {
throw new MoreKeySpecParserError("Unknown resource: " + name);
}
return resId;
}
@SuppressWarnings("serial")
public static class MoreKeySpecParserError extends RuntimeException {
public MoreKeySpecParserError(String message) {
......
......@@ -16,14 +16,6 @@
package com.android.inputmethod.latin;
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.define.JniLibName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -41,6 +33,14 @@ import android.text.format.DateUtils;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.define.JniLibName;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
......@@ -793,4 +793,13 @@ public class Utils {
LatinImeLogger.logOnAutoCorrectionCancelled();
}
}
public static int getResourceId(Resources res, String name, int packageNameResId) {
String packageName = res.getResourcePackageName(packageNameResId);
int resId = res.getIdentifier(name, null, packageName);
if (resId == 0) {
throw new RuntimeException("Unknown resource: " + name);
}
return resId;
}
}
......@@ -66,7 +66,7 @@ public class MoreKeySpecParserTests extends AndroidTestCase {
assertParser(message, moreKeySpec, expectedLabel, expectedOutputText, expectedIcon,
expectedCode);
fail(message);
} catch (MoreKeySpecParser.MoreKeySpecParserError pcpe) {
} catch (Exception pcpe) {
// success.
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment