mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
Minor changes from code inspection results
git-svn-id: https://zxing.googlecode.com/svn/trunk@1589 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
89c421c2bb
commit
655eeb3537
|
@ -114,6 +114,7 @@ public final class CaptureActivityHandler extends Handler {
|
||||||
try {
|
try {
|
||||||
decodeThread.join();
|
decodeThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
// continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Be absolutely sure we don't send any queued up messages
|
// Be absolutely sure we don't send any queued up messages
|
||||||
|
|
|
@ -36,6 +36,7 @@ import android.widget.Button;
|
||||||
* @author dswitkin@google.com (Daniel Switkin)
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
*/
|
*/
|
||||||
public final class HelpActivity extends Activity {
|
public final class HelpActivity extends Activity {
|
||||||
|
|
||||||
private static final String TAG = HelpActivity.class.getSimpleName();
|
private static final String TAG = HelpActivity.class.getSimpleName();
|
||||||
|
|
||||||
// Actually guessing at the Desire's MODEL for now:
|
// Actually guessing at the Desire's MODEL for now:
|
||||||
|
@ -107,9 +108,9 @@ public final class HelpActivity extends Activity {
|
||||||
webView.loadUrl(BASE_URL + DEFAULT_PAGE);
|
webView.loadUrl(BASE_URL + DEFAULT_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
backButton = (Button)findViewById(R.id.back_button);
|
backButton = (Button) findViewById(R.id.back_button);
|
||||||
backButton.setOnClickListener(backListener);
|
backButton.setOnClickListener(backListener);
|
||||||
Button doneButton = (Button)findViewById(R.id.done_button);
|
View doneButton = findViewById(R.id.done_button);
|
||||||
doneButton.setOnClickListener(doneListener);
|
doneButton.setOnClickListener(doneListener);
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
|
|
@ -32,7 +32,8 @@ import com.google.zxing.client.android.R;
|
||||||
* @author dswitkin@google.com (Daniel Switkin)
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
*/
|
*/
|
||||||
final class SearchBookContentsAdapter extends ArrayAdapter<SearchBookContentsResult> {
|
final class SearchBookContentsAdapter extends ArrayAdapter<SearchBookContentsResult> {
|
||||||
public SearchBookContentsAdapter(Context context, List<SearchBookContentsResult> items) {
|
|
||||||
|
SearchBookContentsAdapter(Context context, List<SearchBookContentsResult> items) {
|
||||||
super(context, R.layout.search_book_contents_list_item, 0, items);
|
super(context, R.layout.search_book_contents_list_item, 0, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,8 +118,7 @@ final class CameraConfigurationManager {
|
||||||
return cameraResolution;
|
return cameraResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Point findBestPreviewSizeValue(String previewSizeValueString,
|
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
|
||||||
Point screenResolution) {
|
|
||||||
int bestX = 0;
|
int bestX = 0;
|
||||||
int bestY = 0;
|
int bestY = 0;
|
||||||
int diff = Integer.MAX_VALUE;
|
int diff = Integer.MAX_VALUE;
|
||||||
|
|
|
@ -38,8 +38,8 @@ final class FlashlightManager {
|
||||||
|
|
||||||
private static final String TAG = FlashlightManager.class.getSimpleName();
|
private static final String TAG = FlashlightManager.class.getSimpleName();
|
||||||
|
|
||||||
private static Object iHardwareService;
|
private static final Object iHardwareService;
|
||||||
private static Method setFlashEnabledMethod;
|
private static final Method setFlashEnabledMethod;
|
||||||
static {
|
static {
|
||||||
iHardwareService = getHardwareService();
|
iHardwareService = getHardwareService();
|
||||||
setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
|
setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
|
||||||
|
|
|
@ -204,8 +204,8 @@ final class QRCodeEncoder {
|
||||||
} else if (type.equals(Contents.Type.CONTACT)) {
|
} else if (type.equals(Contents.Type.CONTACT)) {
|
||||||
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
|
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
StringBuilder newContents = new StringBuilder();
|
StringBuilder newContents = new StringBuilder(100);
|
||||||
StringBuilder newDisplayContents = new StringBuilder();
|
StringBuilder newDisplayContents = new StringBuilder(100);
|
||||||
newContents.append("MECARD:");
|
newContents.append("MECARD:");
|
||||||
String name = trim(bundle.getString(Contacts.Intents.Insert.NAME));
|
String name = trim(bundle.getString(Contacts.Intents.Insert.NAME));
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -258,8 +258,8 @@ final class QRCodeEncoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean encodeQRCodeContents(AddressBookParsedResult contact) {
|
private boolean encodeQRCodeContents(AddressBookParsedResult contact) {
|
||||||
StringBuilder newContents = new StringBuilder();
|
StringBuilder newContents = new StringBuilder(100);
|
||||||
StringBuilder newDisplayContents = new StringBuilder();
|
StringBuilder newDisplayContents = new StringBuilder(100);
|
||||||
newContents.append("MECARD:");
|
newContents.append("MECARD:");
|
||||||
String[] names = contact.getNames();
|
String[] names = contact.getNames();
|
||||||
if (names != null && names.length > 0) {
|
if (names != null && names.length > 0) {
|
||||||
|
@ -322,10 +322,10 @@ final class QRCodeEncoder {
|
||||||
BarcodeFormat format,
|
BarcodeFormat format,
|
||||||
int desiredWidth,
|
int desiredWidth,
|
||||||
int desiredHeight) throws WriterException {
|
int desiredHeight) throws WriterException {
|
||||||
Hashtable hints = null;
|
Hashtable<EncodeHintType,Object> hints = null;
|
||||||
String encoding = guessAppropriateEncoding(contents);
|
String encoding = guessAppropriateEncoding(contents);
|
||||||
if (encoding != null) {
|
if (encoding != null) {
|
||||||
hints = new Hashtable(2);
|
hints = new Hashtable<EncodeHintType,Object>(2);
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, encoding);
|
hints.put(EncodeHintType.CHARACTER_SET, encoding);
|
||||||
}
|
}
|
||||||
MultiFormatWriter writer = new MultiFormatWriter();
|
MultiFormatWriter writer = new MultiFormatWriter();
|
||||||
|
|
|
@ -157,7 +157,7 @@ public final class AddressBookResultHandler extends ResultHandler {
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getDisplayContents() {
|
public CharSequence getDisplayContents() {
|
||||||
AddressBookParsedResult result = (AddressBookParsedResult) getResult();
|
AddressBookParsedResult result = (AddressBookParsedResult) getResult();
|
||||||
StringBuffer contents = new StringBuffer();
|
StringBuffer contents = new StringBuffer(100);
|
||||||
ParsedResult.maybeAppend(result.getNames(), contents);
|
ParsedResult.maybeAppend(result.getNames(), contents);
|
||||||
int namesLength = contents.length();
|
int namesLength = contents.length();
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public final class CalendarResultHandler extends ResultHandler {
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getDisplayContents() {
|
public CharSequence getDisplayContents() {
|
||||||
CalendarParsedResult calResult = (CalendarParsedResult) getResult();
|
CalendarParsedResult calResult = (CalendarParsedResult) getResult();
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer(100);
|
||||||
ParsedResult.maybeAppend(calResult.getSummary(), result);
|
ParsedResult.maybeAppend(calResult.getSummary(), result);
|
||||||
appendTime(calResult.getStart(), result);
|
appendTime(calResult.getStart(), result);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Contacts;
|
import android.provider.Contacts;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
|
@ -97,7 +96,7 @@ public abstract class ResultHandler {
|
||||||
|
|
||||||
// Make sure the Shopper button is hidden by default. Without this, scanning a product followed
|
// Make sure the Shopper button is hidden by default. Without this, scanning a product followed
|
||||||
// by a QR Code would leave the button on screen among the QR Code actions.
|
// by a QR Code would leave the button on screen among the QR Code actions.
|
||||||
Button shopperButton = (Button) activity.findViewById(R.id.shopper_button);
|
View shopperButton = activity.findViewById(R.id.shopper_button);
|
||||||
shopperButton.setVisibility(View.GONE);
|
shopperButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +137,7 @@ public abstract class ResultHandler {
|
||||||
* @param listener The on click listener to install for this button.
|
* @param listener The on click listener to install for this button.
|
||||||
*/
|
*/
|
||||||
protected void showGoogleShopperButton(View.OnClickListener listener) {
|
protected void showGoogleShopperButton(View.OnClickListener listener) {
|
||||||
Button shopperButton = (Button) activity.findViewById(R.id.shopper_button);
|
View shopperButton = activity.findViewById(R.id.shopper_button);
|
||||||
shopperButton.setVisibility(View.VISIBLE);
|
shopperButton.setVisibility(View.VISIBLE);
|
||||||
shopperButton.setOnClickListener(listener);
|
shopperButton.setOnClickListener(listener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public final class SMSResultHandler extends ResultHandler {
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getDisplayContents() {
|
public CharSequence getDisplayContents() {
|
||||||
SMSParsedResult smsResult = (SMSParsedResult) getResult();
|
SMSParsedResult smsResult = (SMSParsedResult) getResult();
|
||||||
StringBuffer contents = new StringBuffer();
|
StringBuffer contents = new StringBuffer(50);
|
||||||
String[] rawNumbers = smsResult.getNumbers();
|
String[] rawNumbers = smsResult.getNumbers();
|
||||||
String[] formattedNumbers = new String[rawNumbers.length];
|
String[] formattedNumbers = new String[rawNumbers.length];
|
||||||
for (int i = 0; i < rawNumbers.length; i++) {
|
for (int i = 0; i < rawNumbers.length; i++) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public final class WifiResultHandler extends ResultHandler {
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getDisplayContents() {
|
public CharSequence getDisplayContents() {
|
||||||
WifiParsedResult wifiResult = (WifiParsedResult) getResult();
|
WifiParsedResult wifiResult = (WifiParsedResult) getResult();
|
||||||
StringBuffer contents = new StringBuffer();
|
StringBuffer contents = new StringBuffer(50);
|
||||||
String wifiLabel = parent.getString(R.string.wifi_ssid_label);
|
String wifiLabel = parent.getString(R.string.wifi_ssid_label);
|
||||||
ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
|
ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
|
||||||
String typeLabel = parent.getString(R.string.wifi_type_label);
|
String typeLabel = parent.getString(R.string.wifi_type_label);
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.google.zxing.client.android.share;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
|
@ -31,7 +32,7 @@ import java.util.List;
|
||||||
public final class AppPickerActivity extends ListActivity {
|
public final class AppPickerActivity extends ListActivity {
|
||||||
|
|
||||||
private final List<String[]> labelsPackages = new ArrayList<String[]>();
|
private final List<String[]> labelsPackages = new ArrayList<String[]>();
|
||||||
private ProgressDialog dialog;
|
private DialogInterface dialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
|
@ -58,7 +59,7 @@ public final class AppPickerActivity extends ListActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressDialog getProgressDialog() {
|
DialogInterface getProgressDialog() {
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.os.AsyncTask;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -65,11 +66,7 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(labelsPackages, new Comparator<String[]>() {
|
Collections.sort(labelsPackages, new ByFirstStringComparator());
|
||||||
public int compare(String[] o1, String[] o2) {
|
|
||||||
return o1[0].compareTo(o2[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return labelsPackages;
|
return labelsPackages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,4 +99,10 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
||||||
appPickerActivity.getProgressDialog().dismiss();
|
appPickerActivity.getProgressDialog().dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ByFirstStringComparator implements Comparator<String[]>, Serializable {
|
||||||
|
public int compare(String[] o1, String[] o2) {
|
||||||
|
return o1[0].compareTo(o2[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ final class WifiReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
if (state == NetworkInfo.State.DISCONNECTED){
|
if (state == NetworkInfo.State.DISCONNECTED){
|
||||||
Log.d(TAG, "Got state: " + state + " for ssid: " + ssid);
|
Log.d(TAG, "Got state: " + state + " for ssid: " + ssid);
|
||||||
((WifiActivity)parent).gotError();
|
parent.gotError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue