mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Lots of code cleanup, including 100 column fixes and dead code removal.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1769 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
e7b14f7443
commit
e22dd98452
|
@ -129,7 +129,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
private InactivityTimer inactivityTimer;
|
private InactivityTimer inactivityTimer;
|
||||||
private BeepManager beepManager;
|
private BeepManager beepManager;
|
||||||
|
|
||||||
private final DialogInterface.OnClickListener aboutListener = new DialogInterface.OnClickListener() {
|
private final DialogInterface.OnClickListener aboutListener =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
|
@ -224,7 +225,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
&& (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true));
|
&& (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true));
|
||||||
|
|
||||||
beepManager.updatePrefs();
|
beepManager.updatePrefs();
|
||||||
|
|
||||||
inactivityTimer.onResume();
|
inactivityTimer.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,8 +491,10 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
|
TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
|
||||||
supplementTextView.setText("");
|
supplementTextView.setText("");
|
||||||
supplementTextView.setOnClickListener(null);
|
supplementTextView.setOnClickListener(null);
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL, true)) {
|
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
|
||||||
SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(), handler, this);
|
PreferencesActivity.KEY_SUPPLEMENTAL, true)) {
|
||||||
|
SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
|
||||||
|
handler, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int buttonCount = resultHandler.getButtonCount();
|
int buttonCount = resultHandler.getButtonCount();
|
||||||
|
|
|
@ -49,16 +49,16 @@ final class InactivityTimer {
|
||||||
void onActivity() {
|
void onActivity() {
|
||||||
cancel();
|
cancel();
|
||||||
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
|
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
|
||||||
INACTIVITY_DELAY_SECONDS,
|
INACTIVITY_DELAY_SECONDS,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPause(){
|
public void onPause(){
|
||||||
activity.unregisterReceiver(powerStatusReceiver);
|
activity.unregisterReceiver(powerStatusReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResume(){
|
public void onResume(){
|
||||||
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancel() {
|
private void cancel() {
|
||||||
|
@ -82,18 +82,18 @@ final class InactivityTimer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class PowerStatusReceiver extends BroadcastReceiver {
|
private final class PowerStatusReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent){
|
public void onReceive(Context context, Intent intent){
|
||||||
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
|
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
|
||||||
// 0 indicates that we're on battery
|
// 0 indicates that we're on battery
|
||||||
// In Android 2.0+, use BatteryManager.EXTRA_PLUGGED
|
// In Android 2.0+, use BatteryManager.EXTRA_PLUGGED
|
||||||
if (intent.getIntExtra("plugged", -1) == 0) {
|
if (intent.getIntExtra("plugged", -1) == 0) {
|
||||||
InactivityTimer.this.onActivity();
|
InactivityTimer.this.onActivity();
|
||||||
} else {
|
} else {
|
||||||
InactivityTimer.this.cancel();
|
InactivityTimer.this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,8 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
||||||
private final int left;
|
private final int left;
|
||||||
private final int top;
|
private final int top;
|
||||||
|
|
||||||
public PlanarYUVLuminanceSource(byte[] yuvData,
|
public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
|
||||||
int dataWidth,
|
int width, int height, boolean reverseHorizontal) {
|
||||||
int dataHeight,
|
|
||||||
int left,
|
|
||||||
int top,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
boolean reverseHorizontal) {
|
|
||||||
super(width, height);
|
super(width, height);
|
||||||
|
|
||||||
if (left + width > dataWidth || top + height > dataHeight) {
|
if (left + width > dataWidth || top + height > dataHeight) {
|
||||||
|
@ -112,14 +106,6 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDataWidth() {
|
|
||||||
return dataWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDataHeight() {
|
|
||||||
return dataHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap renderCroppedGreyscaleBitmap() {
|
public Bitmap renderCroppedGreyscaleBitmap() {
|
||||||
int width = getWidth();
|
int width = getWidth();
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
|
|
|
@ -84,7 +84,8 @@ public final class PreferencesActivity extends PreferenceActivity
|
||||||
checked.add(decodeDataMatrix);
|
checked.add(decodeDataMatrix);
|
||||||
}
|
}
|
||||||
boolean disable = checked.size() < 2;
|
boolean disable = checked.size() < 2;
|
||||||
for (CheckBoxPreference pref : new CheckBoxPreference[] {decode1D, decodeQR, decodeDataMatrix}) {
|
CheckBoxPreference[] checkBoxPreferences = {decode1D, decodeQR, decodeDataMatrix};
|
||||||
|
for (CheckBoxPreference pref : checkBoxPreferences) {
|
||||||
pref.setEnabled(!(disable && checked.contains(pref)));
|
pref.setEnabled(!(disable && checked.contains(pref)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ import java.util.regex.Pattern;
|
||||||
final class CameraConfigurationManager {
|
final class CameraConfigurationManager {
|
||||||
|
|
||||||
private static final String TAG = CameraConfigurationManager.class.getSimpleName();
|
private static final String TAG = CameraConfigurationManager.class.getSimpleName();
|
||||||
|
|
||||||
private static final int TEN_DESIRED_ZOOM = 27;
|
private static final int TEN_DESIRED_ZOOM = 27;
|
||||||
private static final int DESIRED_SHARPNESS = 30;
|
|
||||||
|
|
||||||
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
@ -73,7 +70,6 @@ final class CameraConfigurationManager {
|
||||||
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
|
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
|
||||||
setFlash(parameters);
|
setFlash(parameters);
|
||||||
setZoom(parameters);
|
setZoom(parameters);
|
||||||
//setSharpness(parameters);
|
|
||||||
camera.setParameters(parameters);
|
camera.setParameters(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +114,8 @@ final class CameraConfigurationManager {
|
||||||
return cameraResolution;
|
return cameraResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
|
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString,
|
||||||
|
Point screenResolution) {
|
||||||
int bestX = 0;
|
int bestX = 0;
|
||||||
int bestY = 0;
|
int bestY = 0;
|
||||||
int diff = Integer.MAX_VALUE;
|
int diff = Integer.MAX_VALUE;
|
||||||
|
@ -179,11 +176,8 @@ final class CameraConfigurationManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFlash(Camera.Parameters parameters) {
|
private void setFlash(Camera.Parameters parameters) {
|
||||||
// FIXME: This is a hack to turn the flash off on the Samsung Galaxy.
|
// FIXME: This is a hack to turn the flash off on the Samsung Galaxy and the Behold II
|
||||||
// And this is a hack-hack to work around a different value on the Behold II
|
// as advised by Samsung, neither of which respected the official parameter.
|
||||||
// Restrict Behold II check to Cupcake, per Samsung's advice
|
|
||||||
//if (Build.MODEL.contains("Behold II") &&
|
|
||||||
// CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
|
|
||||||
if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
|
if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
|
||||||
parameters.set("flash-value", 1);
|
parameters.set("flash-value", 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,24 +251,4 @@ final class CameraConfigurationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private void setSharpness(Camera.Parameters parameters) {
|
|
||||||
|
|
||||||
int desiredSharpness = DESIRED_SHARPNESS;
|
|
||||||
|
|
||||||
String maxSharpnessString = parameters.get("sharpness-max");
|
|
||||||
if (maxSharpnessString != null) {
|
|
||||||
try {
|
|
||||||
int maxSharpness = Integer.parseInt(maxSharpnessString);
|
|
||||||
if (desiredSharpness > maxSharpness) {
|
|
||||||
desiredSharpness = maxSharpness;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
Log.w(TAG, "Bad sharpness-max: " + maxSharpnessString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parameters.set("sharpness", desiredSharpness);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ public final class CameraManager {
|
||||||
* clear the handler so it will only receive one message.
|
* clear the handler so it will only receive one message.
|
||||||
*/
|
*/
|
||||||
private final PreviewCallback previewCallback;
|
private final PreviewCallback previewCallback;
|
||||||
|
|
||||||
/** Autofocus callbacks arrive here, and are dispatched to the Handler which requested them. */
|
/** Autofocus callbacks arrive here, and are dispatched to the Handler which requested them. */
|
||||||
private final AutoFocusCallback autoFocusCallback;
|
private final AutoFocusCallback autoFocusCallback;
|
||||||
|
|
||||||
|
@ -107,7 +108,6 @@ public final class CameraManager {
|
||||||
// Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
|
// Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
|
||||||
// the more efficient one shot callback, as the older one can swamp the system and cause it
|
// the more efficient one shot callback, as the older one can swamp the system and cause it
|
||||||
// to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
|
// to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
|
||||||
//useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE;
|
|
||||||
useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // 3 = Cupcake
|
useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // 3 = Cupcake
|
||||||
|
|
||||||
previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback);
|
previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback);
|
||||||
|
@ -260,27 +260,6 @@ public final class CameraManager {
|
||||||
return framingRectInPreview;
|
return framingRectInPreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the result points from still resolution coordinates to screen coordinates.
|
|
||||||
*
|
|
||||||
* @param points The points returned by the Reader subclass through Result.getResultPoints().
|
|
||||||
* @return An array of Points scaled to the size of the framing rect and offset appropriately
|
|
||||||
* so they can be drawn in screen coordinates.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
public Point[] convertResultPoints(ResultPoint[] points) {
|
|
||||||
Rect frame = getFramingRectInPreview();
|
|
||||||
int count = points.length;
|
|
||||||
Point[] output = new Point[count];
|
|
||||||
for (int x = 0; x < count; x++) {
|
|
||||||
output[x] = new Point();
|
|
||||||
output[x].x = frame.left + (int) (points[x].getX() + 0.5f);
|
|
||||||
output[x].y = frame.top + (int) (points[x].getY() + 0.5f);
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory method to build the appropriate LuminanceSource object based on the format
|
* A factory method to build the appropriate LuminanceSource object based on the format
|
||||||
* of the preview buffers, as described by Camera.Parameters.
|
* of the preview buffers, as described by Camera.Parameters.
|
||||||
|
@ -295,7 +274,7 @@ public final class CameraManager {
|
||||||
int previewFormat = configManager.getPreviewFormat();
|
int previewFormat = configManager.getPreviewFormat();
|
||||||
String previewFormatString = configManager.getPreviewFormatString();
|
String previewFormatString = configManager.getPreviewFormatString();
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean reverseHorizontal = sharedPrefs.getBoolean(PreferencesActivity.KEY_REVERSE_IMAGE, false);
|
boolean reverseImage = sharedPrefs.getBoolean(PreferencesActivity.KEY_REVERSE_IMAGE, false);
|
||||||
|
|
||||||
switch (previewFormat) {
|
switch (previewFormat) {
|
||||||
// This is the standard Android format which all devices are REQUIRED to support.
|
// This is the standard Android format which all devices are REQUIRED to support.
|
||||||
|
@ -304,26 +283,14 @@ public final class CameraManager {
|
||||||
// This format has never been seen in the wild, but is compatible as we only care
|
// This format has never been seen in the wild, but is compatible as we only care
|
||||||
// about the Y channel, so allow it.
|
// about the Y channel, so allow it.
|
||||||
case PixelFormat.YCbCr_422_SP:
|
case PixelFormat.YCbCr_422_SP:
|
||||||
return new PlanarYUVLuminanceSource(data,
|
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
|
||||||
width,
|
rect.width(), rect.height(), reverseImage);
|
||||||
height,
|
|
||||||
rect.left,
|
|
||||||
rect.top,
|
|
||||||
rect.width(),
|
|
||||||
rect.height(),
|
|
||||||
reverseHorizontal);
|
|
||||||
default:
|
default:
|
||||||
// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
|
// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
|
||||||
// Fortunately, it too has all the Y data up front, so we can read it.
|
// Fortunately, it too has all the Y data up front, so we can read it.
|
||||||
if ("yuv420p".equals(previewFormatString)) {
|
if ("yuv420p".equals(previewFormatString)) {
|
||||||
return new PlanarYUVLuminanceSource(data,
|
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
|
||||||
width,
|
rect.width(), rect.height(), reverseImage);
|
||||||
height,
|
|
||||||
rect.left,
|
|
||||||
rect.top,
|
|
||||||
rect.width(),
|
|
||||||
rect.height(),
|
|
||||||
reverseHorizontal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unsupported picture format: " +
|
throw new IllegalArgumentException("Unsupported picture format: " +
|
||||||
|
|
|
@ -28,10 +28,8 @@ import java.lang.reflect.Method;
|
||||||
* but, classes which allow access to this function still exist on some devices.
|
* but, classes which allow access to this function still exist on some devices.
|
||||||
* This therefore proceeds through a great deal of reflection.
|
* This therefore proceeds through a great deal of reflection.
|
||||||
*
|
*
|
||||||
* See <a href="http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/">
|
* See http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/ and
|
||||||
* http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/</a> and
|
* http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java .
|
||||||
* <a href="http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java">
|
|
||||||
* http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java</a>.
|
|
||||||
* Thanks to Ryan Alford for pointing out the availability of this class.
|
* Thanks to Ryan Alford for pointing out the availability of this class.
|
||||||
*/
|
*/
|
||||||
final class FlashlightManager {
|
final class FlashlightManager {
|
||||||
|
@ -74,7 +72,8 @@ final class FlashlightManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class);
|
Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface",
|
||||||
|
IBinder.class);
|
||||||
if (asInterfaceMethod == null) {
|
if (asInterfaceMethod == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ import com.google.zxing.Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Manages functionality related to scan history.</p>
|
* <p>Manages functionality related to scan history.</p>
|
||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
public final class HistoryManager {
|
public final class HistoryManager {
|
||||||
|
@ -122,7 +122,8 @@ public final class HistoryManager {
|
||||||
Resources res = activity.getResources();
|
Resources res = activity.getResources();
|
||||||
dialogItems[dialogItems.length - 2] = res.getString(R.string.history_send);
|
dialogItems[dialogItems.length - 2] = res.getString(R.string.history_send);
|
||||||
dialogItems[dialogItems.length - 1] = res.getString(R.string.history_clear_text);
|
dialogItems[dialogItems.length - 1] = res.getString(R.string.history_clear_text);
|
||||||
DialogInterface.OnClickListener clickListener = new HistoryClickListener(this, activity, dialogItems, items);
|
DialogInterface.OnClickListener clickListener = new HistoryClickListener(this, activity,
|
||||||
|
dialogItems, items);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(R.string.history_title);
|
builder.setTitle(R.string.history_title);
|
||||||
builder.setItems(dialogItems, clickListener);
|
builder.setItems(dialogItems, clickListener);
|
||||||
|
@ -136,9 +137,7 @@ public final class HistoryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
boolean rememberDuplicates = prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false);
|
if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
|
||||||
|
|
||||||
if (!rememberDuplicates) {
|
|
||||||
deletePrevious(result.getText());
|
deletePrevious(result.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,9 @@ public abstract class ResultHandler {
|
||||||
private static final DateFormat DATE_FORMAT;
|
private static final DateFormat DATE_FORMAT;
|
||||||
static {
|
static {
|
||||||
DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
||||||
// For dates without a time, for purposes of interacting with Android, the resulting timestamp needs to
|
// For dates without a time, for purposes of interacting with Android, the resulting timestamp
|
||||||
// be midnight of that day in GMT (http://code.google.com/p/android/issues/detail?id=8330)
|
// needs to be midnight of that day in GMT. See:
|
||||||
|
// http://code.google.com/p/android/issues/detail?id=8330
|
||||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
}
|
}
|
||||||
private static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
|
private static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
|
||||||
|
@ -265,7 +266,8 @@ public abstract class ResultHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
final void shareByEmail(String contents) {
|
final void shareByEmail(String contents) {
|
||||||
sendEmailFromUri("mailto:", null, activity.getString(R.string.msg_share_subject_line), contents);
|
sendEmailFromUri("mailto:", null, activity.getString(R.string.msg_share_subject_line),
|
||||||
|
contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
final void sendEmail(String address, String subject, String body) {
|
final void sendEmail(String address, String subject, String body) {
|
||||||
|
@ -447,7 +449,8 @@ public abstract class ResultHandler {
|
||||||
|
|
||||||
private String parseCustomSearchURL() {
|
private String parseCustomSearchURL() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
|
String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
|
||||||
|
null);
|
||||||
if (customProductSearch != null && customProductSearch.trim().length() == 0) {
|
if (customProductSearch != null && customProductSearch.trim().length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,8 @@ final class ProductResultInfoRetriever extends SupplementalInfoRetriever {
|
||||||
|
|
||||||
private final String productID;
|
private final String productID;
|
||||||
|
|
||||||
ProductResultInfoRetriever(TextView textView, String productID, Handler handler, Context context) {
|
ProductResultInfoRetriever(TextView textView, String productID, Handler handler,
|
||||||
|
Context context) {
|
||||||
super(textView, handler, context);
|
super(textView, handler, context);
|
||||||
this.productID = productID;
|
this.productID = productID;
|
||||||
}
|
}
|
||||||
|
@ -107,5 +108,4 @@ final class ProductResultInfoRetriever extends SupplementalInfoRetriever {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,17 @@ public abstract class SupplementalInfoRetriever implements Callable<Void> {
|
||||||
return executorInstance;
|
return executorInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void maybeInvokeRetrieval(TextView textView, ParsedResult result, Handler handler, Context context) {
|
public static void maybeInvokeRetrieval(TextView textView, ParsedResult result, Handler handler,
|
||||||
|
Context context) {
|
||||||
SupplementalInfoRetriever retriever = null;
|
SupplementalInfoRetriever retriever = null;
|
||||||
if (result instanceof URIParsedResult) {
|
if (result instanceof URIParsedResult) {
|
||||||
retriever = new URIResultInfoRetriever(textView, (URIParsedResult) result, handler, context);
|
retriever = new URIResultInfoRetriever(textView, (URIParsedResult) result, handler, context);
|
||||||
} else if (result instanceof ProductParsedResult) {
|
} else if (result instanceof ProductParsedResult) {
|
||||||
retriever = new ProductResultInfoRetriever(textView, ((ProductParsedResult) result).getProductID(), handler, context);
|
retriever = new ProductResultInfoRetriever(textView,
|
||||||
|
((ProductParsedResult) result).getProductID(), handler, context);
|
||||||
} else if (result instanceof ISBNParsedResult) {
|
} else if (result instanceof ISBNParsedResult) {
|
||||||
retriever = new ProductResultInfoRetriever(textView, ((ISBNParsedResult) result).getISBN(), handler, context);
|
retriever = new ProductResultInfoRetriever(textView, ((ISBNParsedResult) result).getISBN(),
|
||||||
|
handler, context);
|
||||||
}
|
}
|
||||||
if (retriever != null) {
|
if (retriever != null) {
|
||||||
ExecutorService executor = getExecutorService();
|
ExecutorService executor = getExecutorService();
|
||||||
|
|
|
@ -42,7 +42,8 @@ final class URIResultInfoRetriever extends SupplementalInfoRetriever {
|
||||||
private final URIParsedResult result;
|
private final URIParsedResult result;
|
||||||
private final String redirectString;
|
private final String redirectString;
|
||||||
|
|
||||||
URIResultInfoRetriever(TextView textView, URIParsedResult result, Handler handler, Context context) {
|
URIResultInfoRetriever(TextView textView, URIParsedResult result, Handler handler,
|
||||||
|
Context context) {
|
||||||
super(textView, handler, context);
|
super(textView, handler, context);
|
||||||
redirectString = context.getString(R.string.msg_redirect);
|
redirectString = context.getString(R.string.msg_redirect);
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
|
|
@ -36,8 +36,8 @@ public final class AppPickerActivity extends ListActivity {
|
||||||
if (labelsPackages.isEmpty()) {
|
if (labelsPackages.isEmpty()) {
|
||||||
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
||||||
}
|
}
|
||||||
// otherwise use last copy we loaded -- apps don't change much, and it takes
|
// Otherwise use last copy we loaded -- apps don't change much, and it takes
|
||||||
// forever to load for some reason
|
// forever to load for some reason.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public final class AppPickerActivity extends ListActivity {
|
||||||
if (position >= 0 && position < labelsPackages.size()) {
|
if (position >= 0 && position < labelsPackages.size()) {
|
||||||
String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
|
String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
intent.putExtra(Browser.BookmarkColumns.URL, url);
|
intent.putExtra(Browser.BookmarkColumns.URL, url);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<String[]>> {
|
final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>, Void, List<String[]>> {
|
||||||
|
|
||||||
private static final String[] PKG_PREFIX_WHITELIST = {
|
private static final String[] PKG_PREFIX_WHITELIST = {
|
||||||
"com.google.android.apps.",
|
"com.google.android.apps.",
|
||||||
|
@ -45,7 +45,6 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
||||||
"com.htc",
|
"com.htc",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private final AppPickerActivity activity;
|
private final AppPickerActivity activity;
|
||||||
|
|
||||||
LoadPackagesAsyncTask(AppPickerActivity activity) {
|
LoadPackagesAsyncTask(AppPickerActivity activity) {
|
||||||
|
@ -93,7 +92,8 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
||||||
for (String[] result : results) {
|
for (String[] result : results) {
|
||||||
labels.add(result[0]);
|
labels.add(result[0]);
|
||||||
}
|
}
|
||||||
ListAdapter listAdapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, labels);
|
ListAdapter listAdapter = new ArrayAdapter<String>(activity,
|
||||||
|
android.R.layout.simple_list_item_1, labels);
|
||||||
activity.setListAdapter(listAdapter);
|
activity.setListAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ final class Killer implements Runnable {
|
||||||
Killer(Activity parent) {
|
Killer(Activity parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchIntent(Intent intent) {
|
void launchIntent(Intent intent) {
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import android.text.TextUtils;
|
||||||
* http://chart.apis.google.com/chart?cht=qr&chs=240x240&chl=WIFI:S:linksys;P:mypass;T:WPA;;
|
* http://chart.apis.google.com/chart?cht=qr&chs=240x240&chl=WIFI:S:linksys;P:mypass;T:WPA;;
|
||||||
*
|
*
|
||||||
* TODO(vikrama): Test with binary ssid or password.
|
* TODO(vikrama): Test with binary ssid or password.
|
||||||
*
|
*
|
||||||
* @author Vikram Aggarwal
|
* @author Vikram Aggarwal
|
||||||
*/
|
*/
|
||||||
final class NetworkUtil {
|
final class NetworkUtil {
|
||||||
|
@ -38,7 +38,8 @@ final class NetworkUtil {
|
||||||
/**
|
/**
|
||||||
* Encloses the incoming string inside double quotes, if it isn't already quoted.
|
* Encloses the incoming string inside double quotes, if it isn't already quoted.
|
||||||
* @param string: the input string
|
* @param string: the input string
|
||||||
* @return a quoted string, of the form "input". If the input string is null, it returns null as well.
|
* @return a quoted string, of the form "input". If the input string is null, it returns null
|
||||||
|
* as well.
|
||||||
*/
|
*/
|
||||||
static String convertToQuotedString(String string) {
|
static String convertToQuotedString(String string) {
|
||||||
if (string == null){
|
if (string == null){
|
||||||
|
@ -57,7 +58,8 @@ final class NetworkUtil {
|
||||||
/**
|
/**
|
||||||
* Check if wepKey is a valid hexadecimal string.
|
* Check if wepKey is a valid hexadecimal string.
|
||||||
* @param wepKey the input to be checked
|
* @param wepKey the input to be checked
|
||||||
* @return true if the input string is indeed hex or empty. False if the input string is non-hex or null.
|
* @return true if the input string is indeed hex or empty. False if the input string is non-hex
|
||||||
|
* or null.
|
||||||
*/
|
*/
|
||||||
static boolean isHexWepKey(CharSequence wepKey) {
|
static boolean isHexWepKey(CharSequence wepKey) {
|
||||||
if (wepKey == null) {
|
if (wepKey == null) {
|
||||||
|
@ -68,4 +70,4 @@ final class NetworkUtil {
|
||||||
return (length == 10 || length == 26 || length == 58) && HEX_DIGITS.matcher(wepKey).matches();
|
return (length == 10 || length == 26 || length == 58) && HEX_DIGITS.matcher(wepKey).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.google.zxing.client.android.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A new activity showing the progress of Wifi connection
|
* A new activity showing the progress of Wifi connection
|
||||||
*
|
*
|
||||||
* @author Vikram Aggarwal
|
* @author Vikram Aggarwal
|
||||||
*/
|
*/
|
||||||
public final class WifiActivity extends Activity {
|
public final class WifiActivity extends Activity {
|
||||||
|
@ -106,7 +106,8 @@ public final class WifiActivity extends Activity {
|
||||||
|
|
||||||
private WifiConfiguration changeNetworkCommon(NetworkSetting input){
|
private WifiConfiguration changeNetworkCommon(NetworkSetting input){
|
||||||
statusView.setText(R.string.wifi_creating_network);
|
statusView.setText(R.string.wifi_creating_network);
|
||||||
Log.d(TAG, "Adding new configuration: \nSSID: " + input.getSsid() + "\nType: " + input.getNetworkType());
|
Log.d(TAG, "Adding new configuration: \nSSID: " + input.getSsid() + "\nType: " +
|
||||||
|
input.getNetworkType());
|
||||||
WifiConfiguration config = new WifiConfiguration();
|
WifiConfiguration config = new WifiConfiguration();
|
||||||
|
|
||||||
config.allowedAuthAlgorithms.clear();
|
config.allowedAuthAlgorithms.clear();
|
||||||
|
@ -179,7 +180,8 @@ public final class WifiActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given ssid name exists in the settings, then change its password to the one given here, and save
|
* If the given ssid name exists in the settings, then change its password to the one given here,
|
||||||
|
* and save
|
||||||
* @param ssid
|
* @param ssid
|
||||||
*/
|
*/
|
||||||
private WifiConfiguration findNetworkInExistingConfig(String ssid){
|
private WifiConfiguration findNetworkInExistingConfig(String ssid){
|
||||||
|
@ -307,4 +309,4 @@ public final class WifiActivity extends Activity {
|
||||||
return networkId;
|
return networkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,9 @@ final class WifiReceiver extends BroadcastReceiver {
|
||||||
private final WifiActivity parent;
|
private final WifiActivity parent;
|
||||||
private final TextView statusView;
|
private final TextView statusView;
|
||||||
|
|
||||||
WifiReceiver(WifiManager wifiManager, WifiActivity wifiActivity, TextView statusView, String ssid) {
|
// FIXME: Why is ssid ignored here?
|
||||||
|
WifiReceiver(WifiManager wifiManager, WifiActivity wifiActivity, TextView statusView,
|
||||||
|
String ssid) {
|
||||||
this.parent = wifiActivity;
|
this.parent = wifiActivity;
|
||||||
this.statusView = statusView;
|
this.statusView = statusView;
|
||||||
this.mWifiManager = wifiManager;
|
this.mWifiManager = wifiManager;
|
||||||
|
@ -52,9 +54,11 @@ final class WifiReceiver extends BroadcastReceiver {
|
||||||
(SupplicantState) intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE),
|
(SupplicantState) intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE),
|
||||||
intent.hasExtra(WifiManager.EXTRA_SUPPLICANT_ERROR));
|
intent.hasExtra(WifiManager.EXTRA_SUPPLICANT_ERROR));
|
||||||
} else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)){
|
} else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)){
|
||||||
handleNetworkStateChanged((NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO));
|
handleNetworkStateChanged((NetworkInfo) intent.getParcelableExtra(
|
||||||
|
WifiManager.EXTRA_NETWORK_INFO));
|
||||||
} else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
} else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||||
ConnectivityManager con = (ConnectivityManager) parent.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager con = (ConnectivityManager) parent.getSystemService(
|
||||||
|
Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo[] s = con.getAllNetworkInfo();
|
NetworkInfo[] s = con.getAllNetworkInfo();
|
||||||
for (NetworkInfo i : s){
|
for (NetworkInfo i : s){
|
||||||
if (i.getTypeName().contentEquals("WIFI")){
|
if (i.getTypeName().contentEquals("WIFI")){
|
||||||
|
@ -91,4 +95,4 @@ final class WifiReceiver extends BroadcastReceiver {
|
||||||
parent.gotError();
|
parent.gotError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue