mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Misc code simplification and edits
This commit is contained in:
parent
c89470b2b0
commit
9aa4db5c1f
|
@ -168,7 +168,7 @@ public final class CameraConfigurationUtils {
|
|||
public static void setFocusArea(Camera.Parameters parameters) {
|
||||
if (parameters.getMaxNumFocusAreas() > 0) {
|
||||
Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
|
||||
List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
|
||||
List<Camera.Area> middleArea = buildMiddleArea();
|
||||
Log.i(TAG, "Setting focus area to : " + toString(middleArea));
|
||||
parameters.setFocusAreas(middleArea);
|
||||
} else {
|
||||
|
@ -179,7 +179,7 @@ public final class CameraConfigurationUtils {
|
|||
public static void setMetering(Camera.Parameters parameters) {
|
||||
if (parameters.getMaxNumMeteringAreas() > 0) {
|
||||
Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
|
||||
List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
|
||||
List<Camera.Area> middleArea = buildMiddleArea();
|
||||
Log.i(TAG, "Setting metering area to : " + toString(middleArea));
|
||||
parameters.setMeteringAreas(middleArea);
|
||||
} else {
|
||||
|
@ -187,9 +187,9 @@ public final class CameraConfigurationUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static List<Camera.Area> buildMiddleArea(int areaPer1000) {
|
||||
private static List<Camera.Area> buildMiddleArea() {
|
||||
return Collections.singletonList(
|
||||
new Camera.Area(new Rect(-areaPer1000, -areaPer1000, areaPer1000, areaPer1000), 1));
|
||||
new Camera.Area(new Rect(-AREA_PER_1000, -AREA_PER_1000, AREA_PER_1000, AREA_PER_1000), 1));
|
||||
}
|
||||
|
||||
public static void setVideoStabilization(Camera.Parameters parameters) {
|
||||
|
@ -395,26 +395,25 @@ public final class CameraConfigurationUtils {
|
|||
|
||||
public static String collectStats(CharSequence flattenedParams) {
|
||||
StringBuilder result = new StringBuilder(1000);
|
||||
|
||||
result.append("BOARD=").append(Build.BOARD).append('\n');
|
||||
result.append("BRAND=").append(Build.BRAND).append('\n');
|
||||
result.append("CPU_ABI=").append(Build.CPU_ABI).append('\n');
|
||||
result.append("DEVICE=").append(Build.DEVICE).append('\n');
|
||||
result.append("DISPLAY=").append(Build.DISPLAY).append('\n');
|
||||
result.append("FINGERPRINT=").append(Build.FINGERPRINT).append('\n');
|
||||
result.append("HOST=").append(Build.HOST).append('\n');
|
||||
result.append("ID=").append(Build.ID).append('\n');
|
||||
result.append("MANUFACTURER=").append(Build.MANUFACTURER).append('\n');
|
||||
result.append("MODEL=").append(Build.MODEL).append('\n');
|
||||
result.append("PRODUCT=").append(Build.PRODUCT).append('\n');
|
||||
result.append("TAGS=").append(Build.TAGS).append('\n');
|
||||
result.append("TIME=").append(Build.TIME).append('\n');
|
||||
result.append("TYPE=").append(Build.TYPE).append('\n');
|
||||
result.append("USER=").append(Build.USER).append('\n');
|
||||
result.append("VERSION.CODENAME=").append(Build.VERSION.CODENAME).append('\n');
|
||||
result.append("VERSION.INCREMENTAL=").append(Build.VERSION.INCREMENTAL).append('\n');
|
||||
result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n');
|
||||
result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n');
|
||||
appendStat(result, "BOARD", Build.BOARD);
|
||||
appendStat(result, "BRAND", Build.BRAND);
|
||||
appendStat(result, "CPU_ABI", Build.CPU_ABI);
|
||||
appendStat(result, "DEVICE", Build.DEVICE);
|
||||
appendStat(result, "DISPLAY", Build.DISPLAY);
|
||||
appendStat(result, "FINGERPRINT", Build.FINGERPRINT);
|
||||
appendStat(result, "HOST", Build.HOST);
|
||||
appendStat(result, "ID", Build.ID);
|
||||
appendStat(result, "MANUFACTURER", Build.MANUFACTURER);
|
||||
appendStat(result, "MODEL", Build.MODEL);
|
||||
appendStat(result, "PRODUCT", Build.PRODUCT);
|
||||
appendStat(result, "TAGS", Build.TAGS);
|
||||
appendStat(result, "TIME", Build.TIME);
|
||||
appendStat(result, "TYPE", Build.TYPE);
|
||||
appendStat(result, "USER", Build.USER);
|
||||
appendStat(result, "VERSION.CODENAME", Build.VERSION.CODENAME);
|
||||
appendStat(result, "VERSION.INCREMENTAL", Build.VERSION.INCREMENTAL);
|
||||
appendStat(result, "VERSION.RELEASE", Build.VERSION.RELEASE);
|
||||
appendStat(result, "VERSION.SDK_INT", Build.VERSION.SDK_INT);
|
||||
|
||||
if (flattenedParams != null) {
|
||||
String[] params = SEMICOLON.split(flattenedParams);
|
||||
|
@ -427,4 +426,8 @@ public final class CameraConfigurationUtils {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
private static void appendStat(StringBuilder builder, String stat, Object value) {
|
||||
builder.append(stat).append('=').append(value).append('\n');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ import java.util.List;
|
|||
*/
|
||||
final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>> {
|
||||
|
||||
private static final String[] PKG_PREFIX_WHITELIST = {
|
||||
private static final String[] PKG_PREFIX_SAFELIST = {
|
||||
"com.google.android.apps.",
|
||||
};
|
||||
private static final String[] PKG_PREFIX_BLACKLIST = {
|
||||
private static final String[] PKG_PREFIX_BLOCKLIST = {
|
||||
"com.android.",
|
||||
"android",
|
||||
"com.google.android.",
|
||||
|
@ -65,7 +65,7 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
|||
String packageName = appInfo.packageName;
|
||||
if (!isHidden(packageName)) {
|
||||
CharSequence label = appInfo.loadLabel(packageManager);
|
||||
Drawable icon = appInfo.loadIcon(packageManager);
|
||||
Drawable icon = appInfo.loadIcon(packageManager);
|
||||
if (label != null) {
|
||||
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
|
||||
}
|
||||
|
@ -79,12 +79,12 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
|||
if (packageName == null) {
|
||||
return true;
|
||||
}
|
||||
for (String prefix : PKG_PREFIX_WHITELIST) {
|
||||
for (String prefix : PKG_PREFIX_SAFELIST) {
|
||||
if (packageName.startsWith(prefix)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String prefix : PKG_PREFIX_BLACKLIST) {
|
||||
for (String prefix : PKG_PREFIX_BLOCKLIST) {
|
||||
if (packageName.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<AppInfo> results) {
|
||||
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
|
||||
R.layout.app_picker_list_item,
|
||||
R.id.app_picker_list_item_label,
|
||||
protected void onPostExecute(final List<AppInfo> results) {
|
||||
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
|
||||
R.layout.app_picker_list_item,
|
||||
R.id.app_picker_list_item_label,
|
||||
results) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
|
|
@ -118,7 +118,7 @@ final class MatrixUtil {
|
|||
private MatrixUtil() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
||||
//
|
||||
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
||||
|
@ -179,17 +179,18 @@ final class MatrixUtil {
|
|||
int y1 = coordinates[1];
|
||||
matrix.set(x1, y1, bit);
|
||||
|
||||
int x2;
|
||||
int y2;
|
||||
if (i < 8) {
|
||||
// Right top corner.
|
||||
int x2 = matrix.getWidth() - i - 1;
|
||||
int y2 = 8;
|
||||
matrix.set(x2, y2, bit);
|
||||
x2 = matrix.getWidth() - i - 1;
|
||||
y2 = 8;
|
||||
} else {
|
||||
// Left bottom corner.
|
||||
int x2 = 8;
|
||||
int y2 = matrix.getHeight() - 7 + (i - 8);
|
||||
matrix.set(x2, y2, bit);
|
||||
x2 = 8;
|
||||
y2 = matrix.getHeight() - 7 + (i - 8);
|
||||
}
|
||||
matrix.set(x2, y2, bit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ public final class WifiParsedResultTestCase extends Assert {
|
|||
public void testEscape() {
|
||||
doTest("WIFI:T:WPA;S:test;P:my_password\\\\;;", "test", "my_password\\", "WPA");
|
||||
doTest("WIFI:T:WPA;S:My_WiFi_SSID;P:abc123/;;", "My_WiFi_SSID", "abc123/", "WPA");
|
||||
doTest("WIFI:T:WPA;S:\"foo\\;bar\\\\baz\";;", "\"foo;bar\\baz\"", null, "WPA");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue