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) {
|
public static void setFocusArea(Camera.Parameters parameters) {
|
||||||
if (parameters.getMaxNumFocusAreas() > 0) {
|
if (parameters.getMaxNumFocusAreas() > 0) {
|
||||||
Log.i(TAG, "Old focus areas: " + toString(parameters.getFocusAreas()));
|
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));
|
Log.i(TAG, "Setting focus area to : " + toString(middleArea));
|
||||||
parameters.setFocusAreas(middleArea);
|
parameters.setFocusAreas(middleArea);
|
||||||
} else {
|
} else {
|
||||||
|
@ -179,7 +179,7 @@ public final class CameraConfigurationUtils {
|
||||||
public static void setMetering(Camera.Parameters parameters) {
|
public static void setMetering(Camera.Parameters parameters) {
|
||||||
if (parameters.getMaxNumMeteringAreas() > 0) {
|
if (parameters.getMaxNumMeteringAreas() > 0) {
|
||||||
Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
|
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));
|
Log.i(TAG, "Setting metering area to : " + toString(middleArea));
|
||||||
parameters.setMeteringAreas(middleArea);
|
parameters.setMeteringAreas(middleArea);
|
||||||
} else {
|
} 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(
|
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) {
|
public static void setVideoStabilization(Camera.Parameters parameters) {
|
||||||
|
@ -395,26 +395,25 @@ public final class CameraConfigurationUtils {
|
||||||
|
|
||||||
public static String collectStats(CharSequence flattenedParams) {
|
public static String collectStats(CharSequence flattenedParams) {
|
||||||
StringBuilder result = new StringBuilder(1000);
|
StringBuilder result = new StringBuilder(1000);
|
||||||
|
appendStat(result, "BOARD", Build.BOARD);
|
||||||
result.append("BOARD=").append(Build.BOARD).append('\n');
|
appendStat(result, "BRAND", Build.BRAND);
|
||||||
result.append("BRAND=").append(Build.BRAND).append('\n');
|
appendStat(result, "CPU_ABI", Build.CPU_ABI);
|
||||||
result.append("CPU_ABI=").append(Build.CPU_ABI).append('\n');
|
appendStat(result, "DEVICE", Build.DEVICE);
|
||||||
result.append("DEVICE=").append(Build.DEVICE).append('\n');
|
appendStat(result, "DISPLAY", Build.DISPLAY);
|
||||||
result.append("DISPLAY=").append(Build.DISPLAY).append('\n');
|
appendStat(result, "FINGERPRINT", Build.FINGERPRINT);
|
||||||
result.append("FINGERPRINT=").append(Build.FINGERPRINT).append('\n');
|
appendStat(result, "HOST", Build.HOST);
|
||||||
result.append("HOST=").append(Build.HOST).append('\n');
|
appendStat(result, "ID", Build.ID);
|
||||||
result.append("ID=").append(Build.ID).append('\n');
|
appendStat(result, "MANUFACTURER", Build.MANUFACTURER);
|
||||||
result.append("MANUFACTURER=").append(Build.MANUFACTURER).append('\n');
|
appendStat(result, "MODEL", Build.MODEL);
|
||||||
result.append("MODEL=").append(Build.MODEL).append('\n');
|
appendStat(result, "PRODUCT", Build.PRODUCT);
|
||||||
result.append("PRODUCT=").append(Build.PRODUCT).append('\n');
|
appendStat(result, "TAGS", Build.TAGS);
|
||||||
result.append("TAGS=").append(Build.TAGS).append('\n');
|
appendStat(result, "TIME", Build.TIME);
|
||||||
result.append("TIME=").append(Build.TIME).append('\n');
|
appendStat(result, "TYPE", Build.TYPE);
|
||||||
result.append("TYPE=").append(Build.TYPE).append('\n');
|
appendStat(result, "USER", Build.USER);
|
||||||
result.append("USER=").append(Build.USER).append('\n');
|
appendStat(result, "VERSION.CODENAME", Build.VERSION.CODENAME);
|
||||||
result.append("VERSION.CODENAME=").append(Build.VERSION.CODENAME).append('\n');
|
appendStat(result, "VERSION.INCREMENTAL", Build.VERSION.INCREMENTAL);
|
||||||
result.append("VERSION.INCREMENTAL=").append(Build.VERSION.INCREMENTAL).append('\n');
|
appendStat(result, "VERSION.RELEASE", Build.VERSION.RELEASE);
|
||||||
result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n');
|
appendStat(result, "VERSION.SDK_INT", Build.VERSION.SDK_INT);
|
||||||
result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n');
|
|
||||||
|
|
||||||
if (flattenedParams != null) {
|
if (flattenedParams != null) {
|
||||||
String[] params = SEMICOLON.split(flattenedParams);
|
String[] params = SEMICOLON.split(flattenedParams);
|
||||||
|
@ -427,4 +426,8 @@ public final class CameraConfigurationUtils {
|
||||||
return result.toString();
|
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>> {
|
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.",
|
"com.google.android.apps.",
|
||||||
};
|
};
|
||||||
private static final String[] PKG_PREFIX_BLACKLIST = {
|
private static final String[] PKG_PREFIX_BLOCKLIST = {
|
||||||
"com.android.",
|
"com.android.",
|
||||||
"android",
|
"android",
|
||||||
"com.google.android.",
|
"com.google.android.",
|
||||||
|
@ -65,7 +65,7 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
||||||
String packageName = appInfo.packageName;
|
String packageName = appInfo.packageName;
|
||||||
if (!isHidden(packageName)) {
|
if (!isHidden(packageName)) {
|
||||||
CharSequence label = appInfo.loadLabel(packageManager);
|
CharSequence label = appInfo.loadLabel(packageManager);
|
||||||
Drawable icon = appInfo.loadIcon(packageManager);
|
Drawable icon = appInfo.loadIcon(packageManager);
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
|
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
||||||
if (packageName == null) {
|
if (packageName == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (String prefix : PKG_PREFIX_WHITELIST) {
|
for (String prefix : PKG_PREFIX_SAFELIST) {
|
||||||
if (packageName.startsWith(prefix)) {
|
if (packageName.startsWith(prefix)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String prefix : PKG_PREFIX_BLACKLIST) {
|
for (String prefix : PKG_PREFIX_BLOCKLIST) {
|
||||||
if (packageName.startsWith(prefix)) {
|
if (packageName.startsWith(prefix)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,10 @@ final class LoadPackagesAsyncTask extends AsyncTask<Object,Object,List<AppInfo>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(final List<AppInfo> results) {
|
protected void onPostExecute(final List<AppInfo> results) {
|
||||||
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
|
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
|
||||||
R.layout.app_picker_list_item,
|
R.layout.app_picker_list_item,
|
||||||
R.id.app_picker_list_item_label,
|
R.id.app_picker_list_item_label,
|
||||||
results) {
|
results) {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ final class MatrixUtil {
|
||||||
private MatrixUtil() {
|
private MatrixUtil() {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
// 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
|
// 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];
|
int y1 = coordinates[1];
|
||||||
matrix.set(x1, y1, bit);
|
matrix.set(x1, y1, bit);
|
||||||
|
|
||||||
|
int x2;
|
||||||
|
int y2;
|
||||||
if (i < 8) {
|
if (i < 8) {
|
||||||
// Right top corner.
|
// Right top corner.
|
||||||
int x2 = matrix.getWidth() - i - 1;
|
x2 = matrix.getWidth() - i - 1;
|
||||||
int y2 = 8;
|
y2 = 8;
|
||||||
matrix.set(x2, y2, bit);
|
|
||||||
} else {
|
} else {
|
||||||
// Left bottom corner.
|
// Left bottom corner.
|
||||||
int x2 = 8;
|
x2 = 8;
|
||||||
int y2 = matrix.getHeight() - 7 + (i - 8);
|
y2 = matrix.getHeight() - 7 + (i - 8);
|
||||||
matrix.set(x2, y2, bit);
|
|
||||||
}
|
}
|
||||||
|
matrix.set(x2, y2, bit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ public final class WifiParsedResultTestCase extends Assert {
|
||||||
public void testEscape() {
|
public void testEscape() {
|
||||||
doTest("WIFI:T:WPA;S:test;P:my_password\\\\;;", "test", "my_password\\", "WPA");
|
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: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