├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── custom_icon.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── me │ │ │ └── sudar │ │ │ └── zxingdemo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── me │ │ └── sudar │ │ └── zxingorient │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── screenshots ├── screenshot_1.png └── screenshot_2.png ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── zxing-orient ├── libs │ └── android-core-3.1.0.jar ├── src │ └── main │ │ ├── res │ │ ├── raw │ │ │ └── beep.ogg │ │ ├── drawable │ │ │ ├── ic_launcher.png │ │ │ ├── share_via_barcode.png │ │ │ ├── ic_flash_off_white_18dp.png │ │ │ ├── ic_flash_on_white_18dp.png │ │ │ ├── ic_center_focus_weak_white_18dp.png │ │ │ └── ic_center_focus_strong_white_18dp.png │ │ ├── drawable-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_flash_off_white_18dp.png │ │ │ ├── ic_flash_on_white_18dp.png │ │ │ ├── ic_center_focus_weak_white_18dp.png │ │ │ └── ic_center_focus_strong_white_18dp.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_flash_on_white_18dp.png │ │ │ ├── ic_flash_off_white_18dp.png │ │ │ ├── ic_center_focus_weak_white_18dp.png │ │ │ └── ic_center_focus_strong_white_18dp.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_flash_off_white_18dp.png │ │ │ ├── ic_flash_on_white_18dp.png │ │ │ ├── ic_center_focus_weak_white_18dp.png │ │ │ └── ic_center_focus_strong_white_18dp.png │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── dimens.xml │ │ │ ├── ids.xml │ │ │ ├── themes.xml │ │ │ ├── colors.xml │ │ │ └── arrays.xml │ │ ├── menu │ │ │ └── encode.xml │ │ ├── layout-land │ │ │ └── encode.xml │ │ └── layout │ │ │ └── encode.xml │ │ └── java │ │ ├── com │ │ └── google │ │ │ └── zxing │ │ │ ├── pdf417 │ │ │ ├── encoder │ │ │ │ ├── Compaction.java │ │ │ │ ├── Dimensions.java │ │ │ │ ├── BarcodeRow.java │ │ │ │ └── BarcodeMatrix.java │ │ │ ├── detector │ │ │ │ └── PDF417DetectorResult.java │ │ │ ├── PDF417ResultMetadata.java │ │ │ └── decoder │ │ │ │ ├── BarcodeMetadata.java │ │ │ │ ├── Codeword.java │ │ │ │ └── BarcodeValue.java │ │ │ ├── client │ │ │ ├── android │ │ │ │ ├── IntentSource.java │ │ │ │ ├── encode │ │ │ │ │ ├── Formatter.java │ │ │ │ │ └── VCardTelDisplayFormatter.java │ │ │ │ ├── ViewfinderResultPointCallback.java │ │ │ │ ├── camera │ │ │ │ │ ├── FrontLightMode.java │ │ │ │ │ ├── PreviewCallback.java │ │ │ │ │ └── open │ │ │ │ │ │ └── OpenCameraInterface.java │ │ │ │ ├── FinishListener.java │ │ │ │ └── Preferences.java │ │ │ └── result │ │ │ │ ├── ParsedResultType.java │ │ │ │ ├── ISBNParsedResult.java │ │ │ │ ├── TextParsedResult.java │ │ │ │ ├── BookmarkDoCoMoResultParser.java │ │ │ │ ├── ProductParsedResult.java │ │ │ │ ├── TelResultParser.java │ │ │ │ ├── AbstractDoCoMoResultParser.java │ │ │ │ ├── TelParsedResult.java │ │ │ │ ├── URLTOResultParser.java │ │ │ │ ├── ISBNResultParser.java │ │ │ │ ├── SMTPResultParser.java │ │ │ │ ├── WifiResultParser.java │ │ │ │ ├── EmailAddressParsedResult.java │ │ │ │ ├── SMSTOMMSTOResultParser.java │ │ │ │ ├── ProductResultParser.java │ │ │ │ ├── WifiParsedResult.java │ │ │ │ ├── ParsedResult.java │ │ │ │ ├── URIResultParser.java │ │ │ │ ├── EmailAddressResultParser.java │ │ │ │ ├── EmailDoCoMoResultParser.java │ │ │ │ └── GeoResultParser.java │ │ │ ├── datamatrix │ │ │ └── encoder │ │ │ │ ├── Encoder.java │ │ │ │ ├── SymbolShapeHint.java │ │ │ │ ├── DataMatrixSymbolInfo144.java │ │ │ │ ├── TextEncoder.java │ │ │ │ └── Base256Encoder.java │ │ │ ├── ResultPointCallback.java │ │ │ ├── common │ │ │ ├── reedsolomon │ │ │ │ └── ReedSolomonException.java │ │ │ ├── DetectorResult.java │ │ │ └── detector │ │ │ │ └── MathUtils.java │ │ │ ├── qrcode │ │ │ ├── encoder │ │ │ │ ├── BlockPair.java │ │ │ │ └── ByteMatrix.java │ │ │ ├── detector │ │ │ │ ├── FinderPatternInfo.java │ │ │ │ └── AlignmentPattern.java │ │ │ └── decoder │ │ │ │ ├── ErrorCorrectionLevel.java │ │ │ │ └── QRCodeDecoderMetaData.java │ │ │ ├── WriterException.java │ │ │ ├── ChecksumException.java │ │ │ ├── NotFoundException.java │ │ │ ├── oned │ │ │ ├── rss │ │ │ │ ├── Pair.java │ │ │ │ ├── expanded │ │ │ │ │ ├── decoders │ │ │ │ │ │ ├── DecodedObject.java │ │ │ │ │ │ ├── AI013103decoder.java │ │ │ │ │ │ ├── DecodedChar.java │ │ │ │ │ │ ├── AI01320xDecoder.java │ │ │ │ │ │ ├── BlockParsedResult.java │ │ │ │ │ │ ├── AnyAIDecoder.java │ │ │ │ │ │ ├── AI013x0xDecoder.java │ │ │ │ │ │ ├── DecodedInformation.java │ │ │ │ │ │ ├── AI01weightDecoder.java │ │ │ │ │ │ ├── CurrentParsingState.java │ │ │ │ │ │ ├── AI01AndOtherAIs.java │ │ │ │ │ │ ├── DecodedNumeric.java │ │ │ │ │ │ └── AI01392xDecoder.java │ │ │ │ │ ├── ExpandedRow.java │ │ │ │ │ └── BitArrayBuilder.java │ │ │ │ ├── DataCharacter.java │ │ │ │ └── FinderPattern.java │ │ │ ├── UPCEANWriter.java │ │ │ ├── UPCEANExtensionSupport.java │ │ │ ├── EAN8Reader.java │ │ │ └── UPCAWriter.java │ │ │ ├── FormatException.java │ │ │ ├── multi │ │ │ ├── MultipleBarcodeReader.java │ │ │ └── qrcode │ │ │ │ └── detector │ │ │ │ └── MultiDetector.java │ │ │ ├── aztec │ │ │ ├── encoder │ │ │ │ ├── Token.java │ │ │ │ ├── SimpleToken.java │ │ │ │ ├── AztecCode.java │ │ │ │ └── BinaryShiftToken.java │ │ │ └── AztecDetectorResult.java │ │ │ ├── ReaderException.java │ │ │ ├── Dimension.java │ │ │ ├── BarcodeFormat.java │ │ │ ├── Writer.java │ │ │ └── InvertedLuminanceSource.java │ │ └── me │ │ └── sudar │ │ └── zxingorient │ │ └── ZxingOrientResult.java ├── build.gradle └── publish.gradle ├── gradle.properties └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':zxing-orient' 2 | -------------------------------------------------------------------------------- /screenshots/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/screenshots/screenshot_1.png -------------------------------------------------------------------------------- /screenshots/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/screenshots/screenshot_2.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | 9 | zxing-orient/build -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /zxing-orient/libs/android-core-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/libs/android-core-3.1.0.jar -------------------------------------------------------------------------------- /zxing-orient/src/main/res/raw/beep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/raw/beep.ogg -------------------------------------------------------------------------------- /app/src/main/res/drawable/custom_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/drawable/custom_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/share_via_barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/share_via_barcode.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/ic_flash_off_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/ic_flash_off_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/ic_flash_on_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/ic_flash_on_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-hdpi/ic_flash_off_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-hdpi/ic_flash_off_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-hdpi/ic_flash_on_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-hdpi/ic_flash_on_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xhdpi/ic_flash_on_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xhdpi/ic_flash_on_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xhdpi/ic_flash_off_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xhdpi/ic_flash_off_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xxhdpi/ic_flash_off_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xxhdpi/ic_flash_off_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xxhdpi/ic_flash_on_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xxhdpi/ic_flash_on_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/ic_center_focus_weak_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/ic_center_focus_weak_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable/ic_center_focus_strong_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable/ic_center_focus_strong_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-hdpi/ic_center_focus_weak_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-hdpi/ic_center_focus_weak_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-hdpi/ic_center_focus_strong_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-hdpi/ic_center_focus_strong_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xhdpi/ic_center_focus_weak_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xhdpi/ic_center_focus_weak_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xxhdpi/ic_center_focus_weak_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xxhdpi/ic_center_focus_weak_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xhdpi/ic_center_focus_strong_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xhdpi/ic_center_focus_strong_white_18dp.png -------------------------------------------------------------------------------- /zxing-orient/src/main/res/drawable-xxhdpi/ic_center_focus_strong_white_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b1zantine/ZXing-Orient/HEAD/zxing-orient/src/main/res/drawable-xxhdpi/ic_center_focus_strong_white_18dp.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 01 09:10:41 IST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #FFFFFF 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/me/sudar/zxingdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package me.sudar.zxingorient; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/me/sudar/zxingorient/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package me.sudar.zxingorient; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 28 | 29 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/UPCEANWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned; 18 | 19 | /** 20 | *

Encapsulates functionality and implementation that is common to UPC and EAN families 21 | * of one-dimensional barcodes.

22 | * 23 | * @author aripollak@gmail.com (Ari Pollak) 24 | * @author dsbnatut@gmail.com (Kazuki Nishiura) 25 | */ 26 | public abstract class UPCEANWriter extends OneDimensionalCodeWriter { 27 | 28 | @Override 29 | public int getDefaultMargin() { 30 | // Use a different default more appropriate for UPC/EAN 31 | return UPCEANReader.START_END_PATTERN.length; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/FormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | /** 20 | * Thrown when a barcode was successfully detected, but some aspect of 21 | * the content did not conform to the barcode's format rules. This could have 22 | * been due to a mis-detection. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public final class FormatException extends ReaderException { 27 | 28 | private static final FormatException instance = new FormatException(); 29 | 30 | private FormatException() { 31 | // do nothing 32 | } 33 | 34 | public static FormatException getFormatInstance() { 35 | return instance; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/ViewfinderResultPointCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.ResultPointCallback; 21 | 22 | final class ViewfinderResultPointCallback implements ResultPointCallback { 23 | 24 | private final ViewfinderView viewfinderView; 25 | 26 | ViewfinderResultPointCallback(ViewfinderView viewfinderView) { 27 | this.viewfinderView = viewfinderView; 28 | } 29 | 30 | @Override 31 | public void foundPossibleResultPoint(ResultPoint point) { 32 | viewfinderView.addPossibleResultPoint(point); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/menu/encode.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 24 | 29 | -------------------------------------------------------------------------------- /zxing-orient/publish.gradle: -------------------------------------------------------------------------------- 1 | task generateSourcesJar(type: Jar) { 2 | from android.sourceSets.main.java.srcDirs 3 | classifier 'sources' 4 | } 5 | task generateJavadocs(type: Javadoc) { 6 | source = android.sourceSets.main.java.srcDirs 7 | classpath += project.files(android.getBootClasspath() 8 | .join(File.pathSeparator)) 9 | } 10 | task generateJavaDocsJar(type: Jar) { 11 | from generateJavadocs.destinationDir 12 | classifier 'javadoc' 13 | } 14 | 15 | generateJavaDocsJar.dependsOn generateJavadocs 16 | 17 | artifacts { 18 | // archives generateJavaDocsJar 19 | archives generateSourcesJar 20 | } 21 | 22 | group = 'me.sudar' 23 | version = '2.1.1' 24 | Properties properties = new Properties() 25 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 26 | 27 | bintray { 28 | user = properties.getProperty('BINTRAY_USER') 29 | key = properties.getProperty('BINTRAY_KEY') 30 | pkg { 31 | repo = 'maven' 32 | name = 'ZXing-Orient' 33 | 34 | version { 35 | name = '2.1.1' 36 | released = new Date() 37 | vcsTag = 'v2.1.1' 38 | } 39 | 40 | licenses = ['Apache-2.0'] 41 | vcsUrl = 'https://github.com/SudarAbisheck/ZXing-Orient.git' 42 | websiteUrl = 'https://github.com/SudarAbisheck/ZXing-Orient' 43 | } 44 | configurations = ['archives'] 45 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/detector/PDF417DetectorResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.detector; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.common.BitMatrix; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * @author Guenther Grau 26 | */ 27 | public final class PDF417DetectorResult { 28 | 29 | private final BitMatrix bits; 30 | private final List points; 31 | 32 | public PDF417DetectorResult(BitMatrix bits, List points) { 33 | this.bits = bits; 34 | this.points = points; 35 | } 36 | 37 | public BitMatrix getBits() { 38 | return bits; 39 | } 40 | 41 | public List getPoints() { 42 | return points; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/multi/MultipleBarcodeReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.multi; 18 | 19 | import com.google.zxing.BinaryBitmap; 20 | import com.google.zxing.DecodeHintType; 21 | import com.google.zxing.NotFoundException; 22 | import com.google.zxing.Result; 23 | 24 | import java.util.Map; 25 | 26 | /** 27 | * Implementation of this interface attempt to read several barcodes from one image. 28 | * 29 | * @see com.google.zxing.Reader 30 | * @author Sean Owen 31 | */ 32 | public interface MultipleBarcodeReader { 33 | 34 | Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException; 35 | 36 | Result[] decodeMultiple(BinaryBitmap image, 37 | Map hints) throws NotFoundException; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/TextParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * A simple result type encapsulating a string that has no further 21 | * interpretation. 22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class TextParsedResult extends ParsedResult { 26 | 27 | private final String text; 28 | private final String language; 29 | 30 | public TextParsedResult(String text, String language) { 31 | super(ParsedResultType.TEXT); 32 | this.text = text; 33 | this.language = language; 34 | } 35 | 36 | public String getText() { 37 | return text; 38 | } 39 | 40 | public String getLanguage() { 41 | return language; 42 | } 43 | 44 | @Override 45 | public String getDisplayResult() { 46 | return text; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/camera/FrontLightMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android.camera; 18 | 19 | import android.content.SharedPreferences; 20 | 21 | import com.google.zxing.client.android.Preferences; 22 | 23 | /** 24 | * Enumerates settings of the preference controlling the front light. 25 | */ 26 | public enum FrontLightMode { 27 | 28 | /** Always on. */ 29 | ON, 30 | /** On only when ambient light is low. */ 31 | AUTO, 32 | /** Always off. */ 33 | OFF; 34 | 35 | private static FrontLightMode parse(String modeString) { 36 | return modeString == null ? OFF : valueOf(modeString); 37 | } 38 | 39 | public static FrontLightMode readPref(SharedPreferences sharedPrefs) { 40 | return parse(sharedPrefs.getString(Preferences.KEY_FRONT_LIGHT_MODE, OFF.toString())); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * @author Sean Owen 23 | */ 24 | public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser { 25 | 26 | @Override 27 | public URIParsedResult parse(Result result) { 28 | String rawText = result.getText(); 29 | if (!rawText.startsWith("MEBKM:")) { 30 | return null; 31 | } 32 | String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true); 33 | String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true); 34 | if (rawUri == null) { 35 | return null; 36 | } 37 | String uri = rawUri[0]; 38 | return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/aztec/encoder/Token.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.aztec.encoder; 18 | 19 | import com.google.zxing.common.BitArray; 20 | 21 | abstract class Token { 22 | 23 | static final Token EMPTY = new SimpleToken(null, 0, 0); 24 | 25 | private final Token previous; 26 | 27 | Token(Token previous) { 28 | this.previous = previous; 29 | } 30 | 31 | final Token getPrevious() { 32 | return previous; 33 | } 34 | 35 | final Token add(int value, int bitCount) { 36 | return new SimpleToken(this, value, bitCount); 37 | } 38 | 39 | final Token addBinaryShift(int start, int byteCount) { 40 | //int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21); 41 | return new BinaryShiftToken(this, start, byteCount); 42 | } 43 | 44 | abstract void appendTo(BitArray bitArray, byte[] text); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/ReaderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | /** 20 | * The general exception class throw when something goes wrong during decoding of a barcode. 21 | * This includes, but is not limited to, failing checksums / error correction algorithms, being 22 | * unable to locate finder timing patterns, and so on. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public abstract class ReaderException extends Exception { 27 | 28 | ReaderException() { 29 | // do nothing 30 | } 31 | 32 | // Prevent stack traces from being taken 33 | // srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden? 34 | // This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow. 35 | @Override 36 | public final Throwable fillInStackTrace() { 37 | return null; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | */ 32 | abstract class DecodedObject { 33 | 34 | private final int newPosition; 35 | 36 | DecodedObject(int newPosition){ 37 | this.newPosition = newPosition; 38 | } 39 | 40 | final int getNewPosition() { 41 | return this.newPosition; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/aztec/encoder/SimpleToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.aztec.encoder; 18 | 19 | import com.google.zxing.common.BitArray; 20 | 21 | final class SimpleToken extends Token { 22 | 23 | // For normal words, indicates value and bitCount 24 | private final short value; 25 | private final short bitCount; 26 | 27 | SimpleToken(Token previous, int value, int bitCount) { 28 | super(previous); 29 | this.value = (short) value; 30 | this.bitCount = (short) bitCount; 31 | } 32 | 33 | @Override 34 | void appendTo(BitArray bitArray, byte[] text) { 35 | bitArray.appendBits(value, bitCount); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | int value = this.value & ((1 << bitCount) - 1); 41 | value |= 1 << bitCount; 42 | return '<' + Integer.toBinaryString(value | (1 << bitCount)).substring(1) + '>'; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/FinishListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android; 18 | 19 | import android.app.Activity; 20 | import android.content.DialogInterface; 21 | 22 | /** 23 | * Simple listener used to exit the app in a few cases. 24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class FinishListener implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener { 28 | 29 | private final Activity activityToFinish; 30 | 31 | public FinishListener(Activity activityToFinish) { 32 | this.activityToFinish = activityToFinish; 33 | } 34 | 35 | @Override 36 | public void onCancel(DialogInterface dialogInterface) { 37 | run(); 38 | } 39 | 40 | @Override 41 | public void onClick(DialogInterface dialogInterface, int i) { 42 | run(); 43 | } 44 | 45 | private void run() { 46 | activityToFinish.finish(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/common/DetectorResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.common; 18 | 19 | import com.google.zxing.ResultPoint; 20 | 21 | /** 22 | *

Encapsulates the result of detecting a barcode in an image. This includes the raw 23 | * matrix of black/white pixels corresponding to the barcode, and possibly points of interest 24 | * in the image, like the location of finder patterns or corners of the barcode in the image.

25 | * 26 | * @author Sean Owen 27 | */ 28 | public class DetectorResult { 29 | 30 | private final BitMatrix bits; 31 | private final ResultPoint[] points; 32 | 33 | public DetectorResult(BitMatrix bits, ResultPoint[] points) { 34 | this.bits = bits; 35 | this.points = points; 36 | } 37 | 38 | public final BitMatrix getBits() { 39 | return bits; 40 | } 41 | 42 | public final ResultPoint[] getPoints() { 43 | return points; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/ProductParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author dswitkin@google.com (Daniel Switkin) 21 | */ 22 | public final class ProductParsedResult extends ParsedResult { 23 | 24 | private final String productID; 25 | private final String normalizedProductID; 26 | 27 | ProductParsedResult(String productID) { 28 | this(productID, productID); 29 | } 30 | 31 | ProductParsedResult(String productID, String normalizedProductID) { 32 | super(ParsedResultType.PRODUCT); 33 | this.productID = productID; 34 | this.normalizedProductID = normalizedProductID; 35 | } 36 | 37 | public String getProductID() { 38 | return productID; 39 | } 40 | 41 | public String getNormalizedProductID() { 42 | return normalizedProductID; 43 | } 44 | 45 | @Override 46 | public String getDisplayResult() { 47 | return productID; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/TelResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * Parses a "tel:" URI result, which specifies a phone number. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public final class TelResultParser extends ResultParser { 27 | 28 | @Override 29 | public TelParsedResult parse(Result result) { 30 | String rawText = getMassagedText(result); 31 | if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) { 32 | return null; 33 | } 34 | // Normalize "TEL:" to "tel:" 35 | String telURI = rawText.startsWith("TEL:") ? "tel:" + rawText.substring(4) : rawText; 36 | // Drop tel, query portion 37 | int queryStart = rawText.indexOf('?', 4); 38 | String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart); 39 | return new TelParsedResult(number, telURI, null); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/AbstractDoCoMoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | *

See 21 | * 22 | * DoCoMo's documentation about the result types represented by subclasses of this class.

23 | * 24 | *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less 25 | * on exception-based mechanisms during parsing.

26 | * 27 | * @author Sean Owen 28 | */ 29 | abstract class AbstractDoCoMoResultParser extends ResultParser { 30 | 31 | static String[] matchDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { 32 | return matchPrefixedField(prefix, rawText, ';', trim); 33 | } 34 | 35 | static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { 36 | return matchSinglePrefixedField(prefix, rawText, ';', trim); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/encoder/Dimensions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.encoder; 18 | 19 | /** 20 | * Data object to specify the minimum and maximum number of rows and columns for a PDF417 barcode. 21 | * 22 | * @author qwandor@google.com (Andrew Walbran) 23 | */ 24 | public final class Dimensions { 25 | 26 | private final int minCols; 27 | private final int maxCols; 28 | private final int minRows; 29 | private final int maxRows; 30 | 31 | public Dimensions(int minCols, int maxCols, int minRows, int maxRows) { 32 | this.minCols = minCols; 33 | this.maxCols = maxCols; 34 | this.minRows = minRows; 35 | this.maxRows = maxRows; 36 | } 37 | 38 | public int getMinCols() { 39 | return minCols; 40 | } 41 | 42 | public int getMaxCols() { 43 | return maxCols; 44 | } 45 | 46 | public int getMinRows() { 47 | return minRows; 48 | } 49 | 50 | public int getMaxRows() { 51 | return maxRows; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/qrcode/detector/FinderPatternInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.detector; 18 | 19 | /** 20 | *

Encapsulates information about finder patterns in an image, including the location of 21 | * the three finder patterns, and their estimated module size.

22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class FinderPatternInfo { 26 | 27 | private final FinderPattern bottomLeft; 28 | private final FinderPattern topLeft; 29 | private final FinderPattern topRight; 30 | 31 | public FinderPatternInfo(FinderPattern[] patternCenters) { 32 | this.bottomLeft = patternCenters[0]; 33 | this.topLeft = patternCenters[1]; 34 | this.topRight = patternCenters[2]; 35 | } 36 | 37 | public FinderPattern getBottomLeft() { 38 | return bottomLeft; 39 | } 40 | 41 | public FinderPattern getTopLeft() { 42 | return topLeft; 43 | } 44 | 45 | public FinderPattern getTopRight() { 46 | return topRight; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/TelParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author Sean Owen 21 | */ 22 | public final class TelParsedResult extends ParsedResult { 23 | 24 | private final String number; 25 | private final String telURI; 26 | private final String title; 27 | 28 | public TelParsedResult(String number, String telURI, String title) { 29 | super(ParsedResultType.TEL); 30 | this.number = number; 31 | this.telURI = telURI; 32 | this.title = title; 33 | } 34 | 35 | public String getNumber() { 36 | return number; 37 | } 38 | 39 | public String getTelURI() { 40 | return telURI; 41 | } 42 | 43 | public String getTitle() { 44 | return title; 45 | } 46 | 47 | @Override 48 | public String getDisplayResult() { 49 | StringBuilder result = new StringBuilder(20); 50 | maybeAppend(number, result); 51 | maybeAppend(title, result); 52 | return result.toString(); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/URLTOResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". 23 | * This seems to be used sometimes, but I am not able to find documentation 24 | * on its origin or official format? 25 | * 26 | * @author Sean Owen 27 | */ 28 | public final class URLTOResultParser extends ResultParser { 29 | 30 | @Override 31 | public URIParsedResult parse(Result result) { 32 | String rawText = getMassagedText(result); 33 | if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) { 34 | return null; 35 | } 36 | int titleEnd = rawText.indexOf(':', 6); 37 | if (titleEnd < 0) { 38 | return null; 39 | } 40 | String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); 41 | String uri = rawText.substring(titleEnd + 1); 42 | return new URIParsedResult(uri, title); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/UPCEANExtensionSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned; 18 | 19 | import com.google.zxing.NotFoundException; 20 | import com.google.zxing.ReaderException; 21 | import com.google.zxing.Result; 22 | import com.google.zxing.common.BitArray; 23 | 24 | final class UPCEANExtensionSupport { 25 | 26 | private static final int[] EXTENSION_START_PATTERN = {1,1,2}; 27 | 28 | private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support(); 29 | private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support(); 30 | 31 | Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException { 32 | int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN); 33 | try { 34 | return fiveSupport.decodeRow(rowNumber, row, extensionStartRange); 35 | } catch (ReaderException ignored) { 36 | return twoSupport.decodeRow(rowNumber, row, extensionStartRange); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/ISBNResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | import com.google.zxing.Result; 21 | 22 | /** 23 | * Parses strings of digits that represent a ISBN. 24 | * 25 | * @author jbreiden@google.com (Jeff Breidenbach) 26 | */ 27 | public final class ISBNResultParser extends ResultParser { 28 | 29 | /** 30 | * See ISBN-13 For Dummies 31 | */ 32 | @Override 33 | public ISBNParsedResult parse(Result result) { 34 | BarcodeFormat format = result.getBarcodeFormat(); 35 | if (format != BarcodeFormat.EAN_13) { 36 | return null; 37 | } 38 | String rawText = getMassagedText(result); 39 | int length = rawText.length(); 40 | if (length != 13) { 41 | return null; 42 | } 43 | if (!rawText.startsWith("978") && !rawText.startsWith("979")) { 44 | return null; 45 | } 46 | 47 | return new ISBNParsedResult(rawText); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/DataCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned.rss; 18 | 19 | public class DataCharacter { 20 | 21 | private final int value; 22 | private final int checksumPortion; 23 | 24 | public DataCharacter(int value, int checksumPortion) { 25 | this.value = value; 26 | this.checksumPortion = checksumPortion; 27 | } 28 | 29 | public final int getValue() { 30 | return value; 31 | } 32 | 33 | public final int getChecksumPortion() { 34 | return checksumPortion; 35 | } 36 | 37 | @Override 38 | public final String toString() { 39 | return value + "(" + checksumPortion + ')'; 40 | } 41 | 42 | @Override 43 | public final boolean equals(Object o) { 44 | if(!(o instanceof DataCharacter)) { 45 | return false; 46 | } 47 | DataCharacter that = (DataCharacter) o; 48 | return value == that.value && checksumPortion == that.checksumPortion; 49 | } 50 | 51 | @Override 52 | public final int hashCode() { 53 | return value ^ checksumPortion; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013103decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.common.BitArray; 30 | 31 | /** 32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 33 | */ 34 | final class AI013103decoder extends AI013x0xDecoder { 35 | 36 | AI013103decoder(BitArray information) { 37 | super(information); 38 | } 39 | 40 | @Override 41 | protected void addWeightCode(StringBuilder buf, int weight) { 42 | buf.append("(3103)"); 43 | } 44 | 45 | @Override 46 | protected int checkWeight(int weight) { 47 | return weight; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/aztec/AztecDetectorResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.aztec; 18 | 19 | import com.google.zxing.ResultPoint; 20 | import com.google.zxing.common.BitMatrix; 21 | import com.google.zxing.common.DetectorResult; 22 | 23 | public final class AztecDetectorResult extends DetectorResult { 24 | 25 | private final boolean compact; 26 | private final int nbDatablocks; 27 | private final int nbLayers; 28 | 29 | public AztecDetectorResult(BitMatrix bits, 30 | ResultPoint[] points, 31 | boolean compact, 32 | int nbDatablocks, 33 | int nbLayers) { 34 | super(bits, points); 35 | this.compact = compact; 36 | this.nbDatablocks = nbDatablocks; 37 | this.nbLayers = nbLayers; 38 | } 39 | 40 | public int getNbLayers() { 41 | return nbLayers; 42 | } 43 | 44 | public int getNbDatablocks() { 45 | return nbDatablocks; 46 | } 47 | 48 | public boolean isCompact() { 49 | return compact; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/Dimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | /** 20 | * Simply encapsulates a width and height. 21 | */ 22 | public final class Dimension { 23 | 24 | private final int width; 25 | private final int height; 26 | 27 | public Dimension(int width, int height) { 28 | if (width < 0 || height < 0) { 29 | throw new IllegalArgumentException(); 30 | } 31 | this.width = width; 32 | this.height = height; 33 | } 34 | 35 | public int getWidth() { 36 | return width; 37 | } 38 | 39 | public int getHeight() { 40 | return height; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object other) { 45 | if (other instanceof Dimension) { 46 | Dimension d = (Dimension) other; 47 | return width == d.width && height == d.height; 48 | } 49 | return false; 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return width * 32713 + height; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return width + "x" + height; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/PDF417ResultMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417; 18 | 19 | /** 20 | * @author Guenther Grau 21 | */ 22 | public final class PDF417ResultMetadata { 23 | 24 | private int segmentIndex; 25 | private String fileId; 26 | private int[] optionalData; 27 | private boolean lastSegment; 28 | 29 | public int getSegmentIndex() { 30 | return segmentIndex; 31 | } 32 | 33 | public void setSegmentIndex(int segmentIndex) { 34 | this.segmentIndex = segmentIndex; 35 | } 36 | 37 | public String getFileId() { 38 | return fileId; 39 | } 40 | 41 | public void setFileId(String fileId) { 42 | this.fileId = fileId; 43 | } 44 | 45 | public int[] getOptionalData() { 46 | return optionalData; 47 | } 48 | 49 | public void setOptionalData(int[] optionalData) { 50 | this.optionalData = optionalData; 51 | } 52 | 53 | public boolean isLastSegment() { 54 | return lastSegment; 55 | } 56 | 57 | public void setLastSegment(boolean lastSegment) { 58 | this.lastSegment = lastSegment; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | #ff000000 19 | #ffffffff 20 | #c0ffbd21 21 | #ffc0c0c0 22 | #c099cc00 23 | #ffffffff 24 | #b0000000 25 | #ffffffff 26 | #00000000 27 | #ffcc0000 28 | #60000000 29 | 30 | #ff3F51B5 31 | #AA3F51B5 32 | #ffffffff 33 | 34 | #3F51B5 35 | #303F9F 36 | #FF4081 37 | 38 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedChar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 32 | */ 33 | final class DecodedChar extends DecodedObject { 34 | 35 | private final char value; 36 | 37 | static final char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset 38 | 39 | DecodedChar(int newPosition, char value) { 40 | super(newPosition); 41 | this.value = value; 42 | } 43 | 44 | char getValue(){ 45 | return this.value; 46 | } 47 | 48 | boolean isFNC1(){ 49 | return this.value == FNC1; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/common/detector/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.common.detector; 18 | 19 | public final class MathUtils { 20 | 21 | private MathUtils() { 22 | } 23 | 24 | /** 25 | * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its 26 | * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut 27 | * differ slightly from {@link Math#round(float)} in that half rounds down for negative 28 | * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. 29 | * 30 | * @param d real value to round 31 | * @return nearest {@code int} 32 | */ 33 | public static int round(float d) { 34 | return (int) (d + (d < 0.0f ? -0.5f : 0.5f)); 35 | } 36 | 37 | public static float distance(float aX, float aY, float bX, float bY) { 38 | float xDiff = aX - bX; 39 | float yDiff = aY - bY; 40 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 41 | } 42 | 43 | public static float distance(int aX, int aY, int bX, int bY) { 44 | int xDiff = aX - bX; 45 | int yDiff = aY - bY; 46 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/decoder/BarcodeMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.decoder; 18 | 19 | /** 20 | * @author Guenther Grau 21 | */ 22 | final class BarcodeMetadata { 23 | 24 | private final int columnCount; 25 | private final int errorCorrectionLevel; 26 | private final int rowCountUpperPart; 27 | private final int rowCountLowerPart; 28 | private final int rowCount; 29 | 30 | BarcodeMetadata(int columnCount, int rowCountUpperPart, int rowCountLowerPart, int errorCorrectionLevel) { 31 | this.columnCount = columnCount; 32 | this.errorCorrectionLevel = errorCorrectionLevel; 33 | this.rowCountUpperPart = rowCountUpperPart; 34 | this.rowCountLowerPart = rowCountLowerPart; 35 | this.rowCount = rowCountUpperPart + rowCountLowerPart; 36 | } 37 | 38 | int getColumnCount() { 39 | return columnCount; 40 | } 41 | 42 | int getErrorCorrectionLevel() { 43 | return errorCorrectionLevel; 44 | } 45 | 46 | int getRowCount() { 47 | return rowCount; 48 | } 49 | 50 | int getRowCountUpperPart() { 51 | return rowCountUpperPart; 52 | } 53 | 54 | int getRowCountLowerPart() { 55 | return rowCountLowerPart; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/FinderPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned.rss; 18 | 19 | import com.google.zxing.ResultPoint; 20 | 21 | public final class FinderPattern { 22 | 23 | private final int value; 24 | private final int[] startEnd; 25 | private final ResultPoint[] resultPoints; 26 | 27 | public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) { 28 | this.value = value; 29 | this.startEnd = startEnd; 30 | this.resultPoints = new ResultPoint[] { 31 | new ResultPoint((float) start, (float) rowNumber), 32 | new ResultPoint((float) end, (float) rowNumber), 33 | }; 34 | } 35 | 36 | public int getValue() { 37 | return value; 38 | } 39 | 40 | public int[] getStartEnd() { 41 | return startEnd; 42 | } 43 | 44 | public ResultPoint[] getResultPoints() { 45 | return resultPoints; 46 | } 47 | 48 | @Override 49 | public boolean equals(Object o) { 50 | if(!(o instanceof FinderPattern)) { 51 | return false; 52 | } 53 | FinderPattern that = (FinderPattern) o; 54 | return value == that.value; 55 | } 56 | 57 | @Override 58 | public int hashCode() { 59 | return value; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01320xDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.common.BitArray; 30 | 31 | /** 32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 33 | */ 34 | final class AI01320xDecoder extends AI013x0xDecoder { 35 | 36 | AI01320xDecoder(BitArray information) { 37 | super(information); 38 | } 39 | 40 | @Override 41 | protected void addWeightCode(StringBuilder buf, int weight) { 42 | if (weight < 10000) { 43 | buf.append("(3202)"); 44 | } else { 45 | buf.append("(3203)"); 46 | } 47 | } 48 | 49 | @Override 50 | protected int checkWeight(int weight) { 51 | if(weight < 10000) { 52 | return weight; 53 | } 54 | return weight - 10000; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.decoder; 18 | 19 | /** 20 | *

See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels 21 | * defined by the QR code standard.

22 | * 23 | * @author Sean Owen 24 | */ 25 | public enum ErrorCorrectionLevel { 26 | 27 | /** L = ~7% correction */ 28 | L(0x01), 29 | /** M = ~15% correction */ 30 | M(0x00), 31 | /** Q = ~25% correction */ 32 | Q(0x03), 33 | /** H = ~30% correction */ 34 | H(0x02); 35 | 36 | private static final ErrorCorrectionLevel[] FOR_BITS = {M, L, H, Q}; 37 | 38 | private final int bits; 39 | 40 | ErrorCorrectionLevel(int bits) { 41 | this.bits = bits; 42 | } 43 | 44 | public int getBits() { 45 | return bits; 46 | } 47 | 48 | /** 49 | * @param bits int containing the two bits encoding a QR Code's error correction level 50 | * @return ErrorCorrectionLevel representing the encoded error correction level 51 | */ 52 | public static ErrorCorrectionLevel forBits(int bits) { 53 | if (bits < 0 || bits >= FOR_BITS.length) { 54 | throw new IllegalArgumentException(); 55 | } 56 | return FOR_BITS[bits]; 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/BarcodeFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | /** 20 | * Enumerates barcode formats known to this package. Please keep alphabetized. 21 | * 22 | * @author Sean Owen 23 | */ 24 | public enum BarcodeFormat { 25 | 26 | /** Aztec 2D barcode format. */ 27 | AZTEC, 28 | 29 | /** CODABAR 1D format. */ 30 | CODABAR, 31 | 32 | /** Code 39 1D format. */ 33 | CODE_39, 34 | 35 | /** Code 93 1D format. */ 36 | CODE_93, 37 | 38 | /** Code 128 1D format. */ 39 | CODE_128, 40 | 41 | /** Data Matrix 2D barcode format. */ 42 | DATA_MATRIX, 43 | 44 | /** EAN-8 1D format. */ 45 | EAN_8, 46 | 47 | /** EAN-13 1D format. */ 48 | EAN_13, 49 | 50 | /** ITF (Interleaved Two of Five) 1D format. */ 51 | ITF, 52 | 53 | /** MaxiCode 2D barcode format. */ 54 | MAXICODE, 55 | 56 | /** PDF417 format. */ 57 | PDF_417, 58 | 59 | /** QR Code 2D barcode format. */ 60 | QR_CODE, 61 | 62 | /** RSS 14 */ 63 | RSS_14, 64 | 65 | /** RSS EXPANDED */ 66 | RSS_EXPANDED, 67 | 68 | /** UPC-A 1D format. */ 69 | UPC_A, 70 | 71 | /** UPC-E 1D format. */ 72 | UPC_E, 73 | 74 | /** UPC/EAN extension format. Not a stand-alone format. */ 75 | UPC_EAN_EXTENSION 76 | 77 | } 78 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/SMTPResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | *

Parses an "smtp:" URI result, whose format is not standardized but appears to be like: 23 | * {@code smtp[:subject[:body]]}.

24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class SMTPResultParser extends ResultParser { 28 | 29 | @Override 30 | public EmailAddressParsedResult parse(Result result) { 31 | String rawText = getMassagedText(result); 32 | if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) { 33 | return null; 34 | } 35 | String emailAddress = rawText.substring(5); 36 | String subject = null; 37 | String body = null; 38 | int colon = emailAddress.indexOf(':'); 39 | if (colon >= 0) { 40 | subject = emailAddress.substring(colon + 1); 41 | emailAddress = emailAddress.substring(0, colon); 42 | colon = subject.indexOf(':'); 43 | if (colon >= 0) { 44 | body = subject.substring(colon + 1); 45 | subject = subject.substring(0, colon); 46 | } 47 | } 48 | String mailtoURI = "mailto:" + emailAddress; 49 | return new EmailAddressParsedResult(emailAddress, subject, body, mailtoURI); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/BlockParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 32 | */ 33 | final class BlockParsedResult { 34 | 35 | private final DecodedInformation decodedInformation; 36 | private final boolean finished; 37 | 38 | BlockParsedResult(boolean finished) { 39 | this(null, finished); 40 | } 41 | 42 | BlockParsedResult(DecodedInformation information, boolean finished) { 43 | this.finished = finished; 44 | this.decodedInformation = information; 45 | } 46 | 47 | DecodedInformation getDecodedInformation() { 48 | return this.decodedInformation; 49 | } 50 | 51 | boolean isFinished() { 52 | return this.finished; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/qrcode/decoder/QRCodeDecoderMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.decoder; 18 | 19 | import com.google.zxing.ResultPoint; 20 | 21 | /** 22 | * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the 23 | * decoding caller. Callers are expected to process this. 24 | * 25 | * @see com.google.zxing.common.DecoderResult#getOther() 26 | */ 27 | public final class QRCodeDecoderMetaData { 28 | 29 | private final boolean mirrored; 30 | 31 | QRCodeDecoderMetaData(boolean mirrored) { 32 | this.mirrored = mirrored; 33 | } 34 | 35 | /** 36 | * @return true if the QR Code was mirrored. 37 | */ 38 | public boolean isMirrored() { 39 | return mirrored; 40 | } 41 | 42 | /** 43 | * Apply the result points' order correction due to mirroring. 44 | * 45 | * @param points Array of points to apply mirror correction to. 46 | */ 47 | public void applyMirroredCorrection(ResultPoint[] points) { 48 | if (!mirrored || points == null || points.length < 3) { 49 | return; 50 | } 51 | ResultPoint bottomLeft = points[0]; 52 | points[0] = points[2]; 53 | points[2] = bottomLeft; 54 | // No need to 'fix' top-left and alignment pattern. 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.FormatException; 30 | import com.google.zxing.NotFoundException; 31 | import com.google.zxing.common.BitArray; 32 | 33 | /** 34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 36 | */ 37 | final class AnyAIDecoder extends AbstractExpandedDecoder { 38 | 39 | private static final int HEADER_SIZE = 2 + 1 + 2; 40 | 41 | AnyAIDecoder(BitArray information) { 42 | super(information); 43 | } 44 | 45 | @Override 46 | public String parseInformation() throws NotFoundException, FormatException { 47 | StringBuilder buf = new StringBuilder(); 48 | return this.getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/WifiResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | *

Parses a WIFI configuration string. Strings will be of the form:

23 | * 24 | *

{@code WIFI:T:[network type];S:[network SSID];P:[network password];H:[hidden?];;}

25 | * 26 | *

The fields can appear in any order. Only "S:" is required.

27 | * 28 | * @author Vikram Aggarwal 29 | * @author Sean Owen 30 | */ 31 | public final class WifiResultParser extends ResultParser { 32 | 33 | @Override 34 | public WifiParsedResult parse(Result result) { 35 | String rawText = getMassagedText(result); 36 | if (!rawText.startsWith("WIFI:")) { 37 | return null; 38 | } 39 | String ssid = matchSinglePrefixedField("S:", rawText, ';', false); 40 | if (ssid == null || ssid.isEmpty()) { 41 | return null; 42 | } 43 | String pass = matchSinglePrefixedField("P:", rawText, ';', false); 44 | String type = matchSinglePrefixedField("T:", rawText, ';', false); 45 | if (type == null) { 46 | type = "nopass"; 47 | } 48 | boolean hidden = Boolean.parseBoolean(matchSinglePrefixedField("H:", rawText, ';', false)); 49 | return new WifiParsedResult(type, ssid, pass, hidden); 50 | } 51 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/EmailAddressParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author Sean Owen 21 | */ 22 | public final class EmailAddressParsedResult extends ParsedResult { 23 | 24 | private final String emailAddress; 25 | private final String subject; 26 | private final String body; 27 | private final String mailtoURI; 28 | 29 | EmailAddressParsedResult(String emailAddress, 30 | String subject, 31 | String body, 32 | String mailtoURI) { 33 | super(ParsedResultType.EMAIL_ADDRESS); 34 | this.emailAddress = emailAddress; 35 | this.subject = subject; 36 | this.body = body; 37 | this.mailtoURI = mailtoURI; 38 | } 39 | 40 | public String getEmailAddress() { 41 | return emailAddress; 42 | } 43 | 44 | public String getSubject() { 45 | return subject; 46 | } 47 | 48 | public String getBody() { 49 | return body; 50 | } 51 | 52 | public String getMailtoURI() { 53 | return mailtoURI; 54 | } 55 | 56 | @Override 57 | public String getDisplayResult() { 58 | StringBuilder result = new StringBuilder(30); 59 | maybeAppend(emailAddress, result); 60 | maybeAppend(subject, result); 61 | maybeAppend(body, result); 62 | return result.toString(); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/SMSTOMMSTOResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | *

Parses an "smsto:" URI result, whose format is not standardized but appears to be like: 23 | * {@code smsto:number(:body)}.

24 | * 25 | *

This actually also parses URIs starting with "smsto:", "mmsto:", "SMSTO:", and 26 | * "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI 27 | * for purposes of forwarding to the platform.

28 | * 29 | * @author Sean Owen 30 | */ 31 | public final class SMSTOMMSTOResultParser extends ResultParser { 32 | 33 | @Override 34 | public SMSParsedResult parse(Result result) { 35 | String rawText = getMassagedText(result); 36 | if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") || 37 | rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) { 38 | return null; 39 | } 40 | // Thanks to dominik.wild for suggesting this enhancement to support 41 | // smsto:number:body URIs 42 | String number = rawText.substring(6); 43 | String body = null; 44 | int bodyStart = number.indexOf(':'); 45 | if (bodyStart >= 0) { 46 | body = number.substring(bodyStart + 1); 47 | number = number.substring(0, bodyStart); 48 | } 49 | return new SMSParsedResult(number, null, null, body); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.NotFoundException; 30 | import com.google.zxing.common.BitArray; 31 | 32 | /** 33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 34 | */ 35 | abstract class AI013x0xDecoder extends AI01weightDecoder { 36 | 37 | private static final int HEADER_SIZE = 4 + 1; 38 | private static final int WEIGHT_SIZE = 15; 39 | 40 | AI013x0xDecoder(BitArray information) { 41 | super(information); 42 | } 43 | 44 | @Override 45 | public String parseInformation() throws NotFoundException { 46 | if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { 47 | throw NotFoundException.getNotFoundInstance(); 48 | } 49 | 50 | StringBuilder buf = new StringBuilder(); 51 | 52 | encodeCompressedGtin(buf, HEADER_SIZE); 53 | encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); 54 | 55 | return buf.toString(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | - 20 | AR 21 | AU 22 | BR 23 | BG 24 | CA 25 | CH 26 | CN 27 | CZ 28 | DE 29 | DK 30 | ES 31 | FI 32 | FR 33 | GB 34 | GR 35 | HU 36 | ID 37 | IT 38 | JP 39 | KR 40 | NL 41 | PL 42 | PT 43 | RO 44 | RU 45 | SE 46 | SK 47 | SI 48 | TR 49 | TW 50 | US 51 | 52 | 53 | ON 54 | AUTO 55 | OFF 56 | 57 | 58 | @string/preferences_front_light_on 59 | @string/preferences_front_light_auto 60 | @string/preferences_front_light_off 61 | 62 | 63 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/ProductResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | import com.google.zxing.Result; 21 | import com.google.zxing.oned.UPCEReader; 22 | 23 | /** 24 | * Parses strings of digits that represent a UPC code. 25 | * 26 | * @author dswitkin@google.com (Daniel Switkin) 27 | */ 28 | public final class ProductResultParser extends ResultParser { 29 | 30 | // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. 31 | @Override 32 | public ProductParsedResult parse(Result result) { 33 | BarcodeFormat format = result.getBarcodeFormat(); 34 | if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || 35 | format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { 36 | return null; 37 | } 38 | String rawText = getMassagedText(result); 39 | if (!isStringOfDigits(rawText, rawText.length())) { 40 | return null; 41 | } 42 | // Not actually checking the checksum again here 43 | 44 | String normalizedProductID; 45 | // Expand UPC-E for purposes of searching 46 | if (format == BarcodeFormat.UPC_E && rawText.length() == 8) { 47 | normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); 48 | } else { 49 | normalizedProductID = rawText; 50 | } 51 | 52 | return new ProductParsedResult(rawText, normalizedProductID); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/WifiParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author Vikram Aggarwal 21 | */ 22 | public final class WifiParsedResult extends ParsedResult { 23 | 24 | private final String ssid; 25 | private final String networkEncryption; 26 | private final String password; 27 | private final boolean hidden; 28 | 29 | public WifiParsedResult(String networkEncryption, String ssid, String password) { 30 | this(networkEncryption, ssid, password, false); 31 | } 32 | 33 | public WifiParsedResult(String networkEncryption, String ssid, String password, boolean hidden) { 34 | super(ParsedResultType.WIFI); 35 | this.ssid = ssid; 36 | this.networkEncryption = networkEncryption; 37 | this.password = password; 38 | this.hidden = hidden; 39 | } 40 | 41 | public String getSsid() { 42 | return ssid; 43 | } 44 | 45 | public String getNetworkEncryption() { 46 | return networkEncryption; 47 | } 48 | 49 | public String getPassword() { 50 | return password; 51 | } 52 | 53 | public boolean isHidden() { 54 | return hidden; 55 | } 56 | 57 | @Override 58 | public String getDisplayResult() { 59 | StringBuilder result = new StringBuilder(80); 60 | maybeAppend(ssid, result); 61 | maybeAppend(networkEncryption, result); 62 | maybeAppend(password, result); 63 | maybeAppend(Boolean.toString(hidden), result); 64 | return result.toString(); 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/camera/PreviewCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android.camera; 18 | 19 | import android.graphics.Point; 20 | import android.hardware.Camera; 21 | import android.os.Handler; 22 | import android.os.Message; 23 | import android.util.Log; 24 | 25 | final class PreviewCallback implements Camera.PreviewCallback { 26 | 27 | private static final String TAG = PreviewCallback.class.getSimpleName(); 28 | 29 | private final CameraConfigurationManager configManager; 30 | private Handler previewHandler; 31 | private int previewMessage; 32 | 33 | PreviewCallback(CameraConfigurationManager configManager) { 34 | this.configManager = configManager; 35 | } 36 | 37 | void setHandler(Handler previewHandler, int previewMessage) { 38 | this.previewHandler = previewHandler; 39 | this.previewMessage = previewMessage; 40 | } 41 | 42 | @Override 43 | public void onPreviewFrame(byte[] data, Camera camera) { 44 | Point cameraResolution = configManager.getCameraResolution(); 45 | Handler thePreviewHandler = previewHandler; 46 | if (cameraResolution != null && thePreviewHandler != null) { 47 | Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, 48 | cameraResolution.y, data); 49 | message.sendToTarget(); 50 | previewHandler = null; 51 | } else { 52 | Log.d(TAG, "Got preview callback, but no handler or resolution available"); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/decoder/Codeword.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.decoder; 18 | 19 | /** 20 | * @author Guenther Grau 21 | */ 22 | final class Codeword { 23 | 24 | private static final int BARCODE_ROW_UNKNOWN = -1; 25 | 26 | private final int startX; 27 | private final int endX; 28 | private final int bucket; 29 | private final int value; 30 | private int rowNumber = BARCODE_ROW_UNKNOWN; 31 | 32 | Codeword(int startX, int endX, int bucket, int value) { 33 | this.startX = startX; 34 | this.endX = endX; 35 | this.bucket = bucket; 36 | this.value = value; 37 | } 38 | 39 | boolean hasValidRowNumber() { 40 | return isValidRowNumber(rowNumber); 41 | } 42 | 43 | boolean isValidRowNumber(int rowNumber) { 44 | return rowNumber != BARCODE_ROW_UNKNOWN && bucket == (rowNumber % 3) * 3; 45 | } 46 | 47 | void setRowNumberAsRowIndicatorColumn() { 48 | rowNumber = (value / 30) * 3 + bucket / 3; 49 | } 50 | 51 | int getWidth() { 52 | return endX - startX; 53 | } 54 | 55 | int getStartX() { 56 | return startX; 57 | } 58 | 59 | int getEndX() { 60 | return endX; 61 | } 62 | 63 | int getBucket() { 64 | return bucket; 65 | } 66 | 67 | int getValue() { 68 | return value; 69 | } 70 | 71 | int getRowNumber() { 72 | return rowNumber; 73 | } 74 | 75 | void setRowNumber(int rowNumber) { 76 | this.rowNumber = rowNumber; 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return rowNumber + "|" + value; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 32 | */ 33 | final class DecodedInformation extends DecodedObject { 34 | 35 | private final String newString; 36 | private final int remainingValue; 37 | private final boolean remaining; 38 | 39 | DecodedInformation(int newPosition, String newString){ 40 | super(newPosition); 41 | this.newString = newString; 42 | this.remaining = false; 43 | this.remainingValue = 0; 44 | } 45 | 46 | DecodedInformation(int newPosition, String newString, int remainingValue){ 47 | super(newPosition); 48 | this.remaining = true; 49 | this.remainingValue = remainingValue; 50 | this.newString = newString; 51 | } 52 | 53 | String getNewString(){ 54 | return this.newString; 55 | } 56 | 57 | boolean isRemaining(){ 58 | return this.remaining; 59 | } 60 | 61 | int getRemainingValue(){ 62 | return this.remainingValue; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01weightDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.common.BitArray; 30 | 31 | /** 32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 33 | */ 34 | abstract class AI01weightDecoder extends AI01decoder { 35 | 36 | AI01weightDecoder(BitArray information) { 37 | super(information); 38 | } 39 | 40 | protected final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) { 41 | int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); 42 | addWeightCode(buf, originalWeightNumeric); 43 | 44 | int weightNumeric = checkWeight(originalWeightNumeric); 45 | 46 | int currentDivisor = 100000; 47 | for(int i = 0; i < 5; ++i){ 48 | if (weightNumeric / currentDivisor == 0) { 49 | buf.append('0'); 50 | } 51 | currentDivisor /= 10; 52 | } 53 | buf.append(weightNumeric); 54 | } 55 | 56 | protected abstract void addWeightCode(StringBuilder buf, int weight); 57 | 58 | protected abstract int checkWeight(int weight); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/aztec/encoder/AztecCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.aztec.encoder; 18 | 19 | import com.google.zxing.common.BitMatrix; 20 | 21 | /** 22 | * Aztec 2D code representation 23 | * 24 | * @author Rustam Abdullaev 25 | */ 26 | public final class AztecCode { 27 | 28 | private boolean compact; 29 | private int size; 30 | private int layers; 31 | private int codeWords; 32 | private BitMatrix matrix; 33 | 34 | /** 35 | * @return {@code true} if compact instead of full mode 36 | */ 37 | public boolean isCompact() { 38 | return compact; 39 | } 40 | 41 | public void setCompact(boolean compact) { 42 | this.compact = compact; 43 | } 44 | 45 | /** 46 | * @return size in pixels (width and height) 47 | */ 48 | public int getSize() { 49 | return size; 50 | } 51 | 52 | public void setSize(int size) { 53 | this.size = size; 54 | } 55 | 56 | /** 57 | * @return number of levels 58 | */ 59 | public int getLayers() { 60 | return layers; 61 | } 62 | 63 | public void setLayers(int layers) { 64 | this.layers = layers; 65 | } 66 | 67 | /** 68 | * @return number of data codewords 69 | */ 70 | public int getCodeWords() { 71 | return codeWords; 72 | } 73 | 74 | public void setCodeWords(int codeWords) { 75 | this.codeWords = codeWords; 76 | } 77 | 78 | /** 79 | * @return the symbol image 80 | */ 81 | public BitMatrix getMatrix() { 82 | return matrix; 83 | } 84 | 85 | public void setMatrix(BitMatrix matrix) { 86 | this.matrix = matrix; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/Preferences.java: -------------------------------------------------------------------------------- 1 | package com.google.zxing.client.android; 2 | 3 | 4 | public final class Preferences { 5 | 6 | public static final String KEY_DECODE_1D_PRODUCT = "preferences_decode_1D_product"; 7 | public static final String KEY_DECODE_1D_INDUSTRIAL = "preferences_decode_1D_industrial"; 8 | public static final String KEY_DECODE_QR = "preferences_decode_QR"; 9 | public static final String KEY_DECODE_DATA_MATRIX = "preferences_decode_Data_Matrix"; 10 | public static final String KEY_DECODE_AZTEC = "preferences_decode_Aztec"; 11 | public static final String KEY_DECODE_PDF417 = "preferences_decode_PDF417"; 12 | 13 | public static final String KEY_CUSTOM_PRODUCT_SEARCH = "preferences_custom_product_search"; 14 | 15 | public static final String KEY_PLAY_BEEP = "preferences_play_beep"; 16 | public static final String KEY_VIBRATE = "preferences_vibrate"; 17 | public static final String KEY_COPY_TO_CLIPBOARD = "preferences_copy_to_clipboard"; 18 | public static final String KEY_FRONT_LIGHT_MODE = "preferences_front_light_mode"; 19 | public static final String KEY_BULK_MODE = "preferences_bulk_mode"; 20 | public static final String KEY_REMEMBER_DUPLICATES = "preferences_remember_duplicates"; 21 | public static final String KEY_SUPPLEMENTAL = "preferences_supplemental"; 22 | public static final String KEY_AUTO_FOCUS = "preferences_auto_focus"; 23 | public static final String KEY_INVERT_SCAN = "preferences_invert_scan"; 24 | public static final String KEY_SEARCH_COUNTRY = "preferences_search_country"; 25 | public static final String KEY_DISABLE_AUTO_ORIENTATION = "preferences_orientation"; 26 | 27 | public static final String KEY_DISABLE_CONTINUOUS_FOCUS = "preferences_disable_continuous_focus"; 28 | public static final String KEY_DISABLE_EXPOSURE = "preferences_disable_exposure"; 29 | public static final String KEY_DISABLE_METERING = "preferences_disable_metering"; 30 | public static final String KEY_DISABLE_BARCODE_SCENE_MODE = "preferences_disable_barcode_scene_mode"; 31 | public static final String KEY_AUTO_OPEN_WEB = "preferences_auto_open_web"; 32 | 33 | public static final String KEY_FLASH = "preferences_flash"; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/layout-land/encode.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 26 | 27 | 33 | 34 | 38 | 39 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/decoder/BarcodeValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.decoder; 18 | 19 | import com.google.zxing.pdf417.PDF417Common; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collection; 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | import java.util.Map.Entry; 26 | 27 | /** 28 | * @author Guenther Grau 29 | */ 30 | final class BarcodeValue { 31 | private final Map values = new HashMap<>(); 32 | 33 | /** 34 | * Add an occurrence of a value 35 | */ 36 | void setValue(int value) { 37 | Integer confidence = values.get(value); 38 | if (confidence == null) { 39 | confidence = 0; 40 | } 41 | confidence++; 42 | values.put(value, confidence); 43 | } 44 | 45 | /** 46 | * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence. 47 | * @return an array of int, containing the values with the highest occurrence, or null, if no value was set 48 | */ 49 | int[] getValue() { 50 | int maxConfidence = -1; 51 | Collection result = new ArrayList<>(); 52 | for (Entry entry : values.entrySet()) { 53 | if (entry.getValue() > maxConfidence) { 54 | maxConfidence = entry.getValue(); 55 | result.clear(); 56 | result.add(entry.getKey()); 57 | } else if (entry.getValue() == maxConfidence) { 58 | result.add(entry.getKey()); 59 | } 60 | } 61 | return PDF417Common.toIntArray(result); 62 | } 63 | 64 | public Integer getConfidence(int value) { 65 | return values.get(value); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/Writer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | import com.google.zxing.common.BitMatrix; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * The base class for all objects which encode/generate a barcode image. 25 | * 26 | * @author dswitkin@google.com (Daniel Switkin) 27 | */ 28 | public interface Writer { 29 | 30 | /** 31 | * Encode a barcode using the default settings. 32 | * 33 | * @param contents The contents to encode in the barcode 34 | * @param format The barcode format to generate 35 | * @param width The preferred width in pixels 36 | * @param height The preferred height in pixels 37 | * @return {@link BitMatrix} representing encoded barcode image 38 | * @throws WriterException if contents cannot be encoded legally in a format 39 | */ 40 | BitMatrix encode(String contents, BarcodeFormat format, int width, int height) 41 | throws WriterException; 42 | 43 | /** 44 | * @param contents The contents to encode in the barcode 45 | * @param format The barcode format to generate 46 | * @param width The preferred width in pixels 47 | * @param height The preferred height in pixels 48 | * @param hints Additional parameters to supply to the encoder 49 | * @return {@link BitMatrix} representing encoded barcode image 50 | * @throws WriterException if contents cannot be encoded legally in a format 51 | */ 52 | BitMatrix encode(String contents, 53 | BarcodeFormat format, 54 | int width, 55 | int height, 56 | Map hints) 57 | throws WriterException; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/ParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | *

Abstract class representing the result of decoding a barcode, as more than 21 | * a String -- as some type of structured data. This might be a subclass which represents 22 | * a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw 23 | * decoded string into the most appropriate type of structured representation.

24 | * 25 | *

Thanks to Jeff Griffin for proposing rewrite of these classes that relies less 26 | * on exception-based mechanisms during parsing.

27 | * 28 | * @author Sean Owen 29 | */ 30 | public abstract class ParsedResult { 31 | 32 | private final ParsedResultType type; 33 | 34 | protected ParsedResult(ParsedResultType type) { 35 | this.type = type; 36 | } 37 | 38 | public final ParsedResultType getType() { 39 | return type; 40 | } 41 | 42 | public abstract String getDisplayResult(); 43 | 44 | @Override 45 | public final String toString() { 46 | return getDisplayResult(); 47 | } 48 | 49 | public static void maybeAppend(String value, StringBuilder result) { 50 | if (value != null && !value.isEmpty()) { 51 | // Don't add a newline before the first value 52 | if (result.length() > 0) { 53 | result.append('\n'); 54 | } 55 | result.append(value); 56 | } 57 | } 58 | 59 | public static void maybeAppend(String[] values, StringBuilder result) { 60 | if (values != null) { 61 | for (String value : values) { 62 | maybeAppend(value, result); 63 | } 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/CurrentParsingState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | */ 32 | final class CurrentParsingState { 33 | 34 | private int position; 35 | private State encoding; 36 | 37 | private enum State { 38 | NUMERIC, 39 | ALPHA, 40 | ISO_IEC_646 41 | } 42 | 43 | CurrentParsingState() { 44 | this.position = 0; 45 | this.encoding = State.NUMERIC; 46 | } 47 | 48 | int getPosition() { 49 | return position; 50 | } 51 | 52 | void setPosition(int position) { 53 | this.position = position; 54 | } 55 | 56 | void incrementPosition(int delta) { 57 | position += delta; 58 | } 59 | 60 | boolean isAlpha(){ 61 | return this.encoding == State.ALPHA; 62 | } 63 | 64 | boolean isNumeric(){ 65 | return this.encoding == State.NUMERIC; 66 | } 67 | 68 | boolean isIsoIec646(){ 69 | return this.encoding == State.ISO_IEC_646; 70 | } 71 | 72 | void setNumeric() { 73 | this.encoding = State.NUMERIC; 74 | } 75 | 76 | void setAlpha() { 77 | this.encoding = State.ALPHA; 78 | } 79 | 80 | void setIsoIec646() { 81 | this.encoding = State.ISO_IEC_646; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /zxing-orient/src/main/res/layout/encode.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | 28 | 34 | 35 | 39 | 40 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/aztec/encoder/BinaryShiftToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.aztec.encoder; 18 | 19 | import com.google.zxing.common.BitArray; 20 | 21 | final class BinaryShiftToken extends Token { 22 | 23 | private final short binaryShiftStart; 24 | private final short binaryShiftByteCount; 25 | 26 | BinaryShiftToken(Token previous, 27 | int binaryShiftStart, 28 | int binaryShiftByteCount) { 29 | super(previous); 30 | this.binaryShiftStart = (short) binaryShiftStart; 31 | this.binaryShiftByteCount = (short) binaryShiftByteCount; 32 | } 33 | 34 | @Override 35 | public void appendTo(BitArray bitArray, byte[] text) { 36 | for (int i = 0; i < binaryShiftByteCount; i++) { 37 | if (i == 0 || (i == 31 && binaryShiftByteCount <= 62)) { 38 | // We need a header before the first character, and before 39 | // character 31 when the total byte code is <= 62 40 | bitArray.appendBits(31, 5); // BINARY_SHIFT 41 | if (binaryShiftByteCount > 62) { 42 | bitArray.appendBits(binaryShiftByteCount - 31, 16); 43 | } else if (i == 0) { 44 | // 1 <= binaryShiftByteCode <= 62 45 | bitArray.appendBits(Math.min(binaryShiftByteCount, 31), 5); 46 | } else { 47 | // 32 <= binaryShiftCount <= 62 and i == 31 48 | bitArray.appendBits(binaryShiftByteCount - 31, 5); 49 | } 50 | } 51 | bitArray.appendBits(text[binaryShiftStart + i], 8); 52 | } 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "<" + binaryShiftStart + "::" + (binaryShiftStart + binaryShiftByteCount - 1) + '>'; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/ExpandedRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned.rss.expanded; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. 24 | */ 25 | final class ExpandedRow { 26 | 27 | private final List pairs; 28 | private final int rowNumber; 29 | /** Did this row of the image have to be reversed (mirrored) to recognize the pairs? */ 30 | private final boolean wasReversed; 31 | 32 | ExpandedRow(List pairs, int rowNumber, boolean wasReversed) { 33 | this.pairs = new ArrayList<>(pairs); 34 | this.rowNumber = rowNumber; 35 | this.wasReversed = wasReversed; 36 | } 37 | 38 | List getPairs() { 39 | return this.pairs; 40 | } 41 | 42 | int getRowNumber() { 43 | return this.rowNumber; 44 | } 45 | 46 | boolean isReversed() { 47 | return this.wasReversed; 48 | } 49 | 50 | boolean isEquivalent(List otherPairs) { 51 | return this.pairs.equals(otherPairs); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "{ " + pairs + " }"; 57 | } 58 | 59 | /** 60 | * Two rows are equal if they contain the same pairs in the same order. 61 | */ 62 | @Override 63 | public boolean equals(Object o) { 64 | if (!(o instanceof ExpandedRow)) { 65 | return false; 66 | } 67 | ExpandedRow that = (ExpandedRow) o; 68 | return this.pairs.equals(that.getPairs()) && wasReversed == that.wasReversed; 69 | } 70 | 71 | @Override 72 | public int hashCode() { 73 | return pairs.hashCode() ^ Boolean.valueOf(wasReversed).hashCode(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/URIResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | /** 25 | * Tries to parse results that are a URI of some kind. 26 | * 27 | * @author Sean Owen 28 | */ 29 | public final class URIResultParser extends ResultParser { 30 | 31 | private static final Pattern URL_WITH_PROTOCOL_PATTERN = Pattern.compile("[a-zA-Z0-9]{2,}:"); 32 | private static final Pattern URL_WITHOUT_PROTOCOL_PATTERN = Pattern.compile( 33 | "([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,}" + // host name elements 34 | "(:\\d{1,5})?" + // maybe port 35 | "(/|\\?|$)"); // query, path or nothing 36 | 37 | @Override 38 | public URIParsedResult parse(Result result) { 39 | String rawText = getMassagedText(result); 40 | // We specifically handle the odd "URL" scheme here for simplicity and add "URI" for fun 41 | // Assume anything starting this way really means to be a URI 42 | if (rawText.startsWith("URL:") || rawText.startsWith("URI:")) { 43 | return new URIParsedResult(rawText.substring(4).trim(), null); 44 | } 45 | rawText = rawText.trim(); 46 | return isBasicallyValidURI(rawText) ? new URIParsedResult(rawText, null) : null; 47 | } 48 | 49 | static boolean isBasicallyValidURI(String uri) { 50 | if (uri.contains(" ")) { 51 | // Quick hack check for a common case 52 | return false; 53 | } 54 | Matcher m = URL_WITH_PROTOCOL_PATTERN.matcher(uri); 55 | if (m.find() && m.start() == 0) { // match at start only 56 | return true; 57 | } 58 | m = URL_WITHOUT_PROTOCOL_PATTERN.matcher(uri); 59 | return m.find() && m.start() == 0; 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.FormatException; 30 | import com.google.zxing.NotFoundException; 31 | import com.google.zxing.common.BitArray; 32 | 33 | /** 34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 36 | */ 37 | final class AI01AndOtherAIs extends AI01decoder { 38 | 39 | private static final int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag, 40 | //the second one is the encodation method, and the other two are for the variable length 41 | AI01AndOtherAIs(BitArray information) { 42 | super(information); 43 | } 44 | 45 | @Override 46 | public String parseInformation() throws NotFoundException, FormatException { 47 | StringBuilder buff = new StringBuilder(); 48 | 49 | buff.append("(01)"); 50 | int initialGtinPosition = buff.length(); 51 | int firstGtinDigit = this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4); 52 | buff.append(firstGtinDigit); 53 | 54 | this.encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition); 55 | 56 | return this.getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/qrcode/detector/AlignmentPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.detector; 18 | 19 | import com.google.zxing.ResultPoint; 20 | 21 | /** 22 | *

Encapsulates an alignment pattern, which are the smaller square patterns found in 23 | * all but the simplest QR Codes.

24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class AlignmentPattern extends ResultPoint { 28 | 29 | private final float estimatedModuleSize; 30 | 31 | AlignmentPattern(float posX, float posY, float estimatedModuleSize) { 32 | super(posX, posY); 33 | this.estimatedModuleSize = estimatedModuleSize; 34 | } 35 | 36 | /** 37 | *

Determines if this alignment pattern "about equals" an alignment pattern at the stated 38 | * position and size -- meaning, it is at nearly the same center with nearly the same size.

39 | */ 40 | boolean aboutEquals(float moduleSize, float i, float j) { 41 | if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { 42 | float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); 43 | return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; 44 | } 45 | return false; 46 | } 47 | 48 | /** 49 | * Combines this object's current estimate of a finder pattern position and module size 50 | * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. 51 | */ 52 | AlignmentPattern combineEstimate(float i, float j, float newModuleSize) { 53 | float combinedX = (getX() + j) / 2.0f; 54 | float combinedY = (getY() + i) / 2.0f; 55 | float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; 56 | return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/EAN8Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | import com.google.zxing.NotFoundException; 21 | import com.google.zxing.common.BitArray; 22 | 23 | /** 24 | *

Implements decoding of the EAN-8 format.

25 | * 26 | * @author Sean Owen 27 | */ 28 | public final class EAN8Reader extends UPCEANReader { 29 | 30 | private final int[] decodeMiddleCounters; 31 | 32 | public EAN8Reader() { 33 | decodeMiddleCounters = new int[4]; 34 | } 35 | 36 | @Override 37 | protected int decodeMiddle(BitArray row, 38 | int[] startRange, 39 | StringBuilder result) throws NotFoundException { 40 | int[] counters = decodeMiddleCounters; 41 | counters[0] = 0; 42 | counters[1] = 0; 43 | counters[2] = 0; 44 | counters[3] = 0; 45 | int end = row.getSize(); 46 | int rowOffset = startRange[1]; 47 | 48 | for (int x = 0; x < 4 && rowOffset < end; x++) { 49 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 50 | result.append((char) ('0' + bestMatch)); 51 | for (int counter : counters) { 52 | rowOffset += counter; 53 | } 54 | } 55 | 56 | int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); 57 | rowOffset = middleRange[1]; 58 | 59 | for (int x = 0; x < 4 && rowOffset < end; x++) { 60 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 61 | result.append((char) ('0' + bestMatch)); 62 | for (int counter : counters) { 63 | rowOffset += counter; 64 | } 65 | } 66 | 67 | return rowOffset; 68 | } 69 | 70 | @Override 71 | BarcodeFormat getBarcodeFormat() { 72 | return BarcodeFormat.EAN_8; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/encoder/BarcodeRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.encoder; 18 | 19 | /** 20 | * @author Jacob Haynes 21 | */ 22 | final class BarcodeRow { 23 | 24 | private final byte[] row; 25 | //A tacker for position in the bar 26 | private int currentLocation; 27 | 28 | /** 29 | * Creates a Barcode row of the width 30 | */ 31 | BarcodeRow(int width) { 32 | this.row = new byte[width]; 33 | currentLocation = 0; 34 | } 35 | 36 | /** 37 | * Sets a specific location in the bar 38 | * 39 | * @param x The location in the bar 40 | * @param value Black if true, white if false; 41 | */ 42 | void set(int x, byte value) { 43 | row[x] = value; 44 | } 45 | 46 | /** 47 | * Sets a specific location in the bar 48 | * 49 | * @param x The location in the bar 50 | * @param black Black if true, white if false; 51 | */ 52 | void set(int x, boolean black) { 53 | row[x] = (byte) (black ? 1 : 0); 54 | } 55 | 56 | /** 57 | * @param black A boolean which is true if the bar black false if it is white 58 | * @param width How many spots wide the bar is. 59 | */ 60 | void addBar(boolean black, int width) { 61 | for (int ii = 0; ii < width; ii++) { 62 | set(currentLocation++, black); 63 | } 64 | } 65 | 66 | /* 67 | byte[] getRow() { 68 | return row; 69 | } 70 | */ 71 | 72 | /** 73 | * This function scales the row 74 | * 75 | * @param scale How much you want the image to be scaled, must be greater than or equal to 1. 76 | * @return the scaled row 77 | */ 78 | byte[] getScaledRow(int scale) { 79 | byte[] output = new byte[row.length * scale]; 80 | for (int i = 0; i < output.length; i++) { 81 | output[i] = row[i / scale]; 82 | } 83 | return output; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/EmailAddressResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * Represents a result that encodes an e-mail address, either as a plain address 25 | * like "joe@example.org" or a mailto: URL like "mailto:joe@example.org". 26 | * 27 | * @author Sean Owen 28 | */ 29 | public final class EmailAddressResultParser extends ResultParser { 30 | 31 | @Override 32 | public EmailAddressParsedResult parse(Result result) { 33 | String rawText = getMassagedText(result); 34 | String emailAddress; 35 | if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) { 36 | // If it starts with mailto:, assume it is definitely trying to be an email address 37 | emailAddress = rawText.substring(7); 38 | int queryStart = emailAddress.indexOf('?'); 39 | if (queryStart >= 0) { 40 | emailAddress = emailAddress.substring(0, queryStart); 41 | } 42 | emailAddress = urlDecode(emailAddress); 43 | Map nameValues = parseNameValuePairs(rawText); 44 | String subject = null; 45 | String body = null; 46 | if (nameValues != null) { 47 | if (emailAddress.isEmpty()) { 48 | emailAddress = nameValues.get("to"); 49 | } 50 | subject = nameValues.get("subject"); 51 | body = nameValues.get("body"); 52 | } 53 | return new EmailAddressParsedResult(emailAddress, subject, body, rawText); 54 | } else { 55 | if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) { 56 | return null; 57 | } 58 | emailAddress = rawText; 59 | return new EmailAddressParsedResult(emailAddress, null, null, "mailto:" + emailAddress); 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/EmailDoCoMoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | import java.util.regex.Pattern; 22 | 23 | /** 24 | * Implements the "MATMSG" email message entry format. 25 | * 26 | * Supported keys: TO, SUB, BODY 27 | * 28 | * @author Sean Owen 29 | */ 30 | public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser { 31 | 32 | private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+"); 33 | 34 | @Override 35 | public EmailAddressParsedResult parse(Result result) { 36 | String rawText = getMassagedText(result); 37 | if (!rawText.startsWith("MATMSG:")) { 38 | return null; 39 | } 40 | String[] rawTo = matchDoCoMoPrefixedField("TO:", rawText, true); 41 | if (rawTo == null) { 42 | return null; 43 | } 44 | String to = rawTo[0]; 45 | if (!isBasicallyValidEmailAddress(to)) { 46 | return null; 47 | } 48 | String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false); 49 | String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false); 50 | return new EmailAddressParsedResult(to, subject, body, "mailto:" + to); 51 | } 52 | 53 | /** 54 | * This implements only the most basic checking for an email address's validity -- that it contains 55 | * an '@' and contains no characters disallowed by RFC 2822. This is an overly lenient definition of 56 | * validity. We want to generally be lenient here since this class is only intended to encapsulate what's 57 | * in a barcode, not "judge" it. 58 | */ 59 | static boolean isBasicallyValidEmailAddress(String email) { 60 | return email != null && ATEXT_ALPHANUMERIC.matcher(email).matches() && email.indexOf('@') >= 0; 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | "ZXing Orient" 3 | Settings 4 | Tap on a Button to Scan and see the Result here. 5 | 1D Barcodes 6 | 2D Barcodes 7 | QR Code 8 | Default 9 | Generate Barcodes 10 | Type something here … 11 | Scan Barcodes 12 | For More Info 13 | Check out the Github Repo !! 14 | CODABAR 15 | DATA MATRIX 16 | AZTEC 17 | CODE 128 18 | share Text 19 | share 20 | Generate QR Code 21 | About 22 | 23 | OK 24 | This App needs to access Camera to present you with the Demo. 25 | Vibration Permission is required to present you with the Demo. 26 | 27 | 28 | Sudar Abisheck 29 | http://www.sudar.me 30 | Zxing Orient 31 | An Android Library based on ZXing Library 32 | with support for `Portrait Orientation` and some cool stuffs. 33 | 2.0.0 34 | https://github.com/SudarAbisheck/ZXing-Orient 35 | apache_2_0 36 | true 37 | https://github.com/SudarAbisheck/ZXing-Orient 38 | About 39 | 40 | 41 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/DecodedNumeric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.FormatException; 30 | 31 | /** 32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 33 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 34 | */ 35 | final class DecodedNumeric extends DecodedObject { 36 | 37 | private final int firstDigit; 38 | private final int secondDigit; 39 | 40 | static final int FNC1 = 10; 41 | 42 | DecodedNumeric(int newPosition, int firstDigit, int secondDigit) throws FormatException { 43 | super(newPosition); 44 | 45 | if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { 46 | throw FormatException.getFormatInstance(); 47 | } 48 | 49 | this.firstDigit = firstDigit; 50 | this.secondDigit = secondDigit; 51 | } 52 | 53 | int getFirstDigit(){ 54 | return this.firstDigit; 55 | } 56 | 57 | int getSecondDigit(){ 58 | return this.secondDigit; 59 | } 60 | 61 | int getValue(){ 62 | return this.firstDigit * 10 + this.secondDigit; 63 | } 64 | 65 | boolean isFirstDigitFNC1(){ 66 | return this.firstDigit == FNC1; 67 | } 68 | 69 | boolean isSecondDigitFNC1(){ 70 | return this.secondDigit == FNC1; 71 | } 72 | 73 | boolean isAnyFNC1(){ 74 | return this.firstDigit == FNC1 || this.secondDigit == FNC1; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01392xDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.FormatException; 30 | import com.google.zxing.NotFoundException; 31 | import com.google.zxing.common.BitArray; 32 | 33 | /** 34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 35 | */ 36 | final class AI01392xDecoder extends AI01decoder { 37 | 38 | private static final int HEADER_SIZE = 5 + 1 + 2; 39 | private static final int LAST_DIGIT_SIZE = 2; 40 | 41 | AI01392xDecoder(BitArray information) { 42 | super(information); 43 | } 44 | 45 | @Override 46 | public String parseInformation() throws NotFoundException, FormatException { 47 | if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) { 48 | throw NotFoundException.getNotFoundInstance(); 49 | } 50 | 51 | StringBuilder buf = new StringBuilder(); 52 | 53 | encodeCompressedGtin(buf, HEADER_SIZE); 54 | 55 | int lastAIdigit = 56 | this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); 57 | buf.append("(392"); 58 | buf.append(lastAIdigit); 59 | buf.append(')'); 60 | 61 | DecodedInformation decodedInformation = 62 | this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null); 63 | buf.append(decodedInformation.getNewString()); 64 | 65 | return buf.toString(); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/pdf417/encoder/BarcodeMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.encoder; 18 | 19 | /** 20 | * Holds all of the information for a barcode in a format where it can be easily accessable 21 | * 22 | * @author Jacob Haynes 23 | */ 24 | public final class BarcodeMatrix { 25 | 26 | private final BarcodeRow[] matrix; 27 | private int currentRow; 28 | private final int height; 29 | private final int width; 30 | 31 | /** 32 | * @param height the height of the matrix (Rows) 33 | * @param width the width of the matrix (Cols) 34 | */ 35 | BarcodeMatrix(int height, int width) { 36 | matrix = new BarcodeRow[height]; 37 | //Initializes the array to the correct width 38 | for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) { 39 | matrix[i] = new BarcodeRow((width + 4) * 17 + 1); 40 | } 41 | this.width = width * 17; 42 | this.height = height; 43 | this.currentRow = -1; 44 | } 45 | 46 | void set(int x, int y, byte value) { 47 | matrix[y].set(x, value); 48 | } 49 | 50 | /* 51 | void setMatrix(int x, int y, boolean black) { 52 | set(x, y, (byte) (black ? 1 : 0)); 53 | } 54 | */ 55 | 56 | void startRow() { 57 | ++currentRow; 58 | } 59 | 60 | BarcodeRow getCurrentRow() { 61 | return matrix[currentRow]; 62 | } 63 | 64 | public byte[][] getMatrix() { 65 | return getScaledMatrix(1, 1); 66 | } 67 | 68 | /* 69 | public byte[][] getScaledMatrix(int scale) { 70 | return getScaledMatrix(scale, scale); 71 | } 72 | */ 73 | 74 | public byte[][] getScaledMatrix(int xScale, int yScale) { 75 | byte[][] matrixOut = new byte[height * yScale][width * xScale]; 76 | int yMax = height * yScale; 77 | for (int i = 0; i < yMax; i++) { 78 | matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale); 79 | } 80 | return matrixOut; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/result/GeoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | /** 25 | * Parses a "geo:" URI result, which specifies a location on the surface of 26 | * the Earth as well as an optional altitude above the surface. See 27 | * 28 | * http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00. 29 | * 30 | * @author Sean Owen 31 | */ 32 | public final class GeoResultParser extends ResultParser { 33 | 34 | private static final Pattern GEO_URL_PATTERN = 35 | Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); 36 | 37 | @Override 38 | public GeoParsedResult parse(Result result) { 39 | CharSequence rawText = getMassagedText(result); 40 | Matcher matcher = GEO_URL_PATTERN.matcher(rawText); 41 | if (!matcher.matches()) { 42 | return null; 43 | } 44 | 45 | String query = matcher.group(4); 46 | 47 | double latitude; 48 | double longitude; 49 | double altitude; 50 | try { 51 | latitude = Double.parseDouble(matcher.group(1)); 52 | if (latitude > 90.0 || latitude < -90.0) { 53 | return null; 54 | } 55 | longitude = Double.parseDouble(matcher.group(2)); 56 | if (longitude > 180.0 || longitude < -180.0) { 57 | return null; 58 | } 59 | if (matcher.group(3) == null) { 60 | altitude = 0.0; 61 | } else { 62 | altitude = Double.parseDouble(matcher.group(3)); 63 | if (altitude < 0.0) { 64 | return null; 65 | } 66 | } 67 | } catch (NumberFormatException ignored) { 68 | return null; 69 | } 70 | return new GeoParsedResult(latitude, longitude, altitude, query); 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /zxing-orient/src/main/java/me/sudar/zxingorient/ZxingOrientResult.java: -------------------------------------------------------------------------------- 1 | package me.sudar.zxingorient; 2 | 3 | public final class ZxingOrientResult { 4 | 5 | private final String contents; 6 | private final String formatName; 7 | private final byte[] rawBytes; 8 | private final Integer orientation; 9 | private final String errorCorrectionLevel; 10 | 11 | ZxingOrientResult() { 12 | this(null, null, null, null, null); 13 | } 14 | 15 | ZxingOrientResult(String contents, 16 | String formatName, 17 | byte[] rawBytes, 18 | Integer orientation, 19 | String errorCorrectionLevel) { 20 | this.contents = contents; 21 | this.formatName = formatName; 22 | this.rawBytes = rawBytes; 23 | this.orientation = orientation; 24 | this.errorCorrectionLevel = errorCorrectionLevel; 25 | } 26 | 27 | /** 28 | * @return raw content of barcode 29 | */ 30 | public String getContents() { 31 | return contents; 32 | } 33 | 34 | /** 35 | * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names. 36 | */ 37 | public String getFormatName() { 38 | return formatName; 39 | } 40 | 41 | /** 42 | * @return raw bytes of the barcode content, if applicable, or null otherwise 43 | */ 44 | public byte[] getRawBytes() { 45 | return rawBytes; 46 | } 47 | 48 | /** 49 | * @return rotation of the image, in degrees, which resulted in a successful scan. May be null. 50 | */ 51 | public Integer getOrientation() { 52 | return orientation; 53 | } 54 | 55 | /** 56 | * @return name of the error correction level used in the barcode, if applicable 57 | */ 58 | public String getErrorCorrectionLevel() { 59 | return errorCorrectionLevel; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | StringBuilder dialogText = new StringBuilder(100); 65 | dialogText.append("Format: ").append(formatName).append('\n'); 66 | dialogText.append("Contents: ").append(contents).append('\n'); 67 | int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; 68 | dialogText.append("Raw bytes: (").append(rawBytesLength).append(" bytes)\n"); 69 | dialogText.append("Orientation: ").append(orientation).append('\n'); 70 | dialogText.append("EC level: ").append(errorCorrectionLevel).append('\n'); 71 | return dialogText.toString(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/encode/VCardTelDisplayFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android.encode; 18 | 19 | import android.telephony.PhoneNumberUtils; 20 | 21 | import java.util.Iterator; 22 | import java.util.List; 23 | import java.util.Map; 24 | import java.util.Set; 25 | 26 | /** 27 | * @author Sean Owen 28 | */ 29 | final class VCardTelDisplayFormatter implements Formatter { 30 | 31 | private final List>> metadataForIndex; 32 | 33 | VCardTelDisplayFormatter() { 34 | this(null); 35 | } 36 | 37 | VCardTelDisplayFormatter(List>> metadataForIndex) { 38 | this.metadataForIndex = metadataForIndex; 39 | } 40 | 41 | @Override 42 | public CharSequence format(CharSequence value, int index) { 43 | value = PhoneNumberUtils.formatNumber(value.toString()); 44 | Map> metadata = 45 | metadataForIndex == null || metadataForIndex.size() <= index ? null : metadataForIndex.get(index); 46 | value = formatMetadata(value, metadata); 47 | return value; 48 | } 49 | 50 | private static CharSequence formatMetadata(CharSequence value, Map> metadata) { 51 | if (metadata == null || metadata.isEmpty()) { 52 | return value; 53 | } 54 | StringBuilder withMetadata = new StringBuilder(); 55 | for (Map.Entry> metadatum : metadata.entrySet()) { 56 | Set values = metadatum.getValue(); 57 | if (values == null || values.isEmpty()) { 58 | continue; 59 | } 60 | Iterator valuesIt = values.iterator(); 61 | withMetadata.append(valuesIt.next()); 62 | while (valuesIt.hasNext()) { 63 | withMetadata.append(',').append(valuesIt.next()); 64 | } 65 | } 66 | if (withMetadata.length() > 0) { 67 | withMetadata.append(' '); 68 | } 69 | withMetadata.append(value); 70 | return withMetadata; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/datamatrix/encoder/TextEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 Jeremias Maerki. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.datamatrix.encoder; 18 | 19 | final class TextEncoder extends C40Encoder { 20 | 21 | @Override 22 | public int getEncodingMode() { 23 | return HighLevelEncoder.TEXT_ENCODATION; 24 | } 25 | 26 | @Override 27 | int encodeChar(char c, StringBuilder sb) { 28 | if (c == ' ') { 29 | sb.append('\3'); 30 | return 1; 31 | } 32 | if (c >= '0' && c <= '9') { 33 | sb.append((char) (c - 48 + 4)); 34 | return 1; 35 | } 36 | if (c >= 'a' && c <= 'z') { 37 | sb.append((char) (c - 97 + 14)); 38 | return 1; 39 | } 40 | if (c >= '\0' && c <= '\u001f') { 41 | sb.append('\0'); //Shift 1 Set 42 | sb.append(c); 43 | return 2; 44 | } 45 | if (c >= '!' && c <= '/') { 46 | sb.append('\1'); //Shift 2 Set 47 | sb.append((char) (c - 33)); 48 | return 2; 49 | } 50 | if (c >= ':' && c <= '@') { 51 | sb.append('\1'); //Shift 2 Set 52 | sb.append((char) (c - 58 + 15)); 53 | return 2; 54 | } 55 | if (c >= '[' && c <= '_') { 56 | sb.append('\1'); //Shift 2 Set 57 | sb.append((char) (c - 91 + 22)); 58 | return 2; 59 | } 60 | if (c == '\u0060') { 61 | sb.append('\2'); //Shift 3 Set 62 | sb.append((char) (c - 96)); 63 | return 2; 64 | } 65 | if (c >= 'A' && c <= 'Z') { 66 | sb.append('\2'); //Shift 3 Set 67 | sb.append((char) (c - 65 + 1)); 68 | return 2; 69 | } 70 | if (c >= '{' && c <= '\u007f') { 71 | sb.append('\2'); //Shift 3 Set 72 | sb.append((char) (c - 123 + 27)); 73 | return 2; 74 | } 75 | if (c >= '\u0080') { 76 | sb.append("\1\u001e"); //Shift 2, Upper Shift 77 | int len = 2; 78 | len += encodeChar((char) (c - 128), sb); 79 | return len; 80 | } 81 | HighLevelEncoder.illegalCharacter(c); 82 | return -1; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/multi/qrcode/detector/MultiDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.multi.qrcode.detector; 18 | 19 | import com.google.zxing.DecodeHintType; 20 | import com.google.zxing.NotFoundException; 21 | import com.google.zxing.ReaderException; 22 | import com.google.zxing.ResultPointCallback; 23 | import com.google.zxing.common.BitMatrix; 24 | import com.google.zxing.common.DetectorResult; 25 | import com.google.zxing.qrcode.detector.Detector; 26 | import com.google.zxing.qrcode.detector.FinderPatternInfo; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.Map; 31 | 32 | /** 33 | *

Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code 34 | * is rotated or skewed, or partially obscured.

35 | * 36 | * @author Sean Owen 37 | * @author Hannes Erven 38 | */ 39 | public final class MultiDetector extends Detector { 40 | 41 | private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0]; 42 | 43 | public MultiDetector(BitMatrix image) { 44 | super(image); 45 | } 46 | 47 | public DetectorResult[] detectMulti(Map hints) throws NotFoundException { 48 | BitMatrix image = getImage(); 49 | ResultPointCallback resultPointCallback = 50 | hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); 51 | MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); 52 | FinderPatternInfo[] infos = finder.findMulti(hints); 53 | 54 | if (infos.length == 0) { 55 | throw NotFoundException.getNotFoundInstance(); 56 | } 57 | 58 | List result = new ArrayList<>(); 59 | for (FinderPatternInfo info : infos) { 60 | try { 61 | result.add(processFinderPatternInfo(info)); 62 | } catch (ReaderException e) { 63 | // ignore 64 | } 65 | } 66 | if (result.isEmpty()) { 67 | return EMPTY_DETECTOR_RESULTS; 68 | } else { 69 | return result.toArray(new DetectorResult[result.size()]); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/UPCAWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | import com.google.zxing.EncodeHintType; 21 | import com.google.zxing.Writer; 22 | import com.google.zxing.WriterException; 23 | import com.google.zxing.common.BitMatrix; 24 | 25 | import java.util.Map; 26 | 27 | /** 28 | * This object renders a UPC-A code as a {@link BitMatrix}. 29 | * 30 | * @author qwandor@google.com (Andrew Walbran) 31 | */ 32 | public final class UPCAWriter implements Writer { 33 | 34 | private final EAN13Writer subWriter = new EAN13Writer(); 35 | 36 | @Override 37 | public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) 38 | throws WriterException { 39 | return encode(contents, format, width, height, null); 40 | } 41 | 42 | @Override 43 | public BitMatrix encode(String contents, 44 | BarcodeFormat format, 45 | int width, 46 | int height, 47 | Map hints) throws WriterException { 48 | if (format != BarcodeFormat.UPC_A) { 49 | throw new IllegalArgumentException("Can only encode UPC-A, but got " + format); 50 | } 51 | return subWriter.encode(preencode(contents), BarcodeFormat.EAN_13, width, height, hints); 52 | } 53 | 54 | /** 55 | * Transform a UPC-A code into the equivalent EAN-13 code, and add a check digit if it is not 56 | * already present. 57 | */ 58 | private static String preencode(String contents) { 59 | int length = contents.length(); 60 | if (length == 11) { 61 | // No check digit present, calculate it and add it 62 | int sum = 0; 63 | for (int i = 0; i < 11; ++i) { 64 | sum += (contents.charAt(i) - '0') * (i % 2 == 0 ? 3 : 1); 65 | } 66 | contents += (1000 - sum) % 10; 67 | } else if (length != 12) { 68 | throw new IllegalArgumentException( 69 | "Requested contents should be 11 or 12 digits long, but got " + contents.length()); 70 | } 71 | return '0' + contents; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded; 28 | 29 | import com.google.zxing.common.BitArray; 30 | 31 | import java.util.List; 32 | 33 | /** 34 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 35 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 36 | */ 37 | final class BitArrayBuilder { 38 | 39 | private BitArrayBuilder() { 40 | } 41 | 42 | static BitArray buildBitArray(List pairs) { 43 | int charNumber = (pairs.size() * 2) - 1; 44 | if (pairs.get(pairs.size() - 1).getRightChar() == null) { 45 | charNumber -= 1; 46 | } 47 | 48 | int size = 12 * charNumber; 49 | 50 | BitArray binary = new BitArray(size); 51 | int accPos = 0; 52 | 53 | ExpandedPair firstPair = pairs.get(0); 54 | int firstValue = firstPair.getRightChar().getValue(); 55 | for(int i = 11; i >= 0; --i){ 56 | if ((firstValue & (1 << i)) != 0) { 57 | binary.set(accPos); 58 | } 59 | accPos++; 60 | } 61 | 62 | for(int i = 1; i < pairs.size(); ++i){ 63 | ExpandedPair currentPair = pairs.get(i); 64 | 65 | int leftValue = currentPair.getLeftChar().getValue(); 66 | for(int j = 11; j >= 0; --j){ 67 | if ((leftValue & (1 << j)) != 0) { 68 | binary.set(accPos); 69 | } 70 | accPos++; 71 | } 72 | 73 | if(currentPair.getRightChar() != null){ 74 | int rightValue = currentPair.getRightChar().getValue(); 75 | for(int j = 11; j >= 0; --j){ 76 | if ((rightValue & (1 << j)) != 0) { 77 | binary.set(accPos); 78 | } 79 | accPos++; 80 | } 81 | } 82 | } 83 | return binary; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/qrcode/encoder/ByteMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.encoder; 18 | 19 | /** 20 | * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned 21 | * -1, 0, and 1, I'm going to use less memory and go with bytes. 22 | * 23 | * @author dswitkin@google.com (Daniel Switkin) 24 | */ 25 | public final class ByteMatrix { 26 | 27 | private final byte[][] bytes; 28 | private final int width; 29 | private final int height; 30 | 31 | public ByteMatrix(int width, int height) { 32 | bytes = new byte[height][width]; 33 | this.width = width; 34 | this.height = height; 35 | } 36 | 37 | public int getHeight() { 38 | return height; 39 | } 40 | 41 | public int getWidth() { 42 | return width; 43 | } 44 | 45 | public byte get(int x, int y) { 46 | return bytes[y][x]; 47 | } 48 | 49 | /** 50 | * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y) 51 | */ 52 | public byte[][] getArray() { 53 | return bytes; 54 | } 55 | 56 | public void set(int x, int y, byte value) { 57 | bytes[y][x] = value; 58 | } 59 | 60 | public void set(int x, int y, int value) { 61 | bytes[y][x] = (byte) value; 62 | } 63 | 64 | public void set(int x, int y, boolean value) { 65 | bytes[y][x] = (byte) (value ? 1 : 0); 66 | } 67 | 68 | public void clear(byte value) { 69 | for (int y = 0; y < height; ++y) { 70 | for (int x = 0; x < width; ++x) { 71 | bytes[y][x] = value; 72 | } 73 | } 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | StringBuilder result = new StringBuilder(2 * width * height + 2); 79 | for (int y = 0; y < height; ++y) { 80 | for (int x = 0; x < width; ++x) { 81 | switch (bytes[y][x]) { 82 | case 0: 83 | result.append(" 0"); 84 | break; 85 | case 1: 86 | result.append(" 1"); 87 | break; 88 | default: 89 | result.append(" "); 90 | break; 91 | } 92 | } 93 | result.append('\n'); 94 | } 95 | return result.toString(); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/datamatrix/encoder/Base256Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 Jeremias Maerki. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.datamatrix.encoder; 18 | 19 | final class Base256Encoder implements Encoder { 20 | 21 | @Override 22 | public int getEncodingMode() { 23 | return HighLevelEncoder.BASE256_ENCODATION; 24 | } 25 | 26 | @Override 27 | public void encode(EncoderContext context) { 28 | StringBuilder buffer = new StringBuilder(); 29 | buffer.append('\0'); //Initialize length field 30 | while (context.hasMoreCharacters()) { 31 | char c = context.getCurrentChar(); 32 | buffer.append(c); 33 | 34 | context.pos++; 35 | 36 | int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), context.pos, getEncodingMode()); 37 | if (newMode != getEncodingMode()) { 38 | context.signalEncoderChange(newMode); 39 | break; 40 | } 41 | } 42 | int dataCount = buffer.length() - 1; 43 | int lengthFieldSize = 1; 44 | int currentSize = context.getCodewordCount() + dataCount + lengthFieldSize; 45 | context.updateSymbolInfo(currentSize); 46 | boolean mustPad = (context.getSymbolInfo().getDataCapacity() - currentSize) > 0; 47 | if (context.hasMoreCharacters() || mustPad) { 48 | if (dataCount <= 249) { 49 | buffer.setCharAt(0, (char) dataCount); 50 | } else if (dataCount > 249 && dataCount <= 1555) { 51 | buffer.setCharAt(0, (char) ((dataCount / 250) + 249)); 52 | buffer.insert(1, (char) (dataCount % 250)); 53 | } else { 54 | throw new IllegalStateException( 55 | "Message length not in valid ranges: " + dataCount); 56 | } 57 | } 58 | for (int i = 0, c = buffer.length(); i < c; i++) { 59 | context.writeCodeword(randomize255State( 60 | buffer.charAt(i), context.getCodewordCount() + 1)); 61 | } 62 | } 63 | 64 | private static char randomize255State(char ch, int codewordPosition) { 65 | int pseudoRandom = ((149 * codewordPosition) % 255) + 1; 66 | int tempVariable = ch + pseudoRandom; 67 | if (tempVariable <= 255) { 68 | return (char) tempVariable; 69 | } else { 70 | return (char) (tempVariable - 256); 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/client/android/camera/open/OpenCameraInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.android.camera.open; 18 | 19 | import android.hardware.Camera; 20 | import android.util.Log; 21 | 22 | public final class OpenCameraInterface { 23 | 24 | private static final String TAG = OpenCameraInterface.class.getName(); 25 | 26 | private OpenCameraInterface() { 27 | } 28 | 29 | 30 | /** 31 | * Opens the requested camera with {@link Camera#open(int)}, if one exists. 32 | * 33 | * @param cameraId camera ID of the camera to use. A negative value means "no preference" 34 | * @return handle to {@link Camera} that was opened 35 | */ 36 | public static Camera open(int cameraId) { 37 | 38 | int numCameras = Camera.getNumberOfCameras(); 39 | if (numCameras == 0) { 40 | Log.w(TAG, "No cameras!"); 41 | return null; 42 | } 43 | 44 | boolean explicitRequest = cameraId >= 0; 45 | 46 | if (!explicitRequest) { 47 | // Select a camera if no explicit camera requested 48 | int index = 0; 49 | while (index < numCameras) { 50 | Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 51 | Camera.getCameraInfo(index, cameraInfo); 52 | if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { 53 | break; 54 | } 55 | index++; 56 | } 57 | 58 | cameraId = index; 59 | } 60 | 61 | Camera camera; 62 | if (cameraId < numCameras) { 63 | Log.i(TAG, "Opening camera #" + cameraId); 64 | camera = Camera.open(cameraId); 65 | } else { 66 | if (explicitRequest) { 67 | Log.w(TAG, "Requested camera does not exist: " + cameraId); 68 | camera = null; 69 | } else { 70 | Log.i(TAG, "No camera facing back; returning camera #0"); 71 | camera = Camera.open(0); 72 | } 73 | } 74 | 75 | return camera; 76 | } 77 | 78 | 79 | /** 80 | * Opens a rear-facing camera with {@link Camera#open(int)}, if one exists, or opens camera 0. 81 | * 82 | * @return handle to {@link Camera} that was opened 83 | */ 84 | public static Camera open() { 85 | return open(-1); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /zxing-orient/src/main/java/com/google/zxing/InvertedLuminanceSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing; 18 | 19 | /** 20 | * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes 21 | * white and vice versa, and each value becomes (255-value). 22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class InvertedLuminanceSource extends LuminanceSource { 26 | 27 | private final LuminanceSource delegate; 28 | 29 | public InvertedLuminanceSource(LuminanceSource delegate) { 30 | super(delegate.getWidth(), delegate.getHeight()); 31 | this.delegate = delegate; 32 | } 33 | 34 | @Override 35 | public byte[] getRow(int y, byte[] row) { 36 | row = delegate.getRow(y, row); 37 | int width = getWidth(); 38 | for (int i = 0; i < width; i++) { 39 | row[i] = (byte) (255 - (row[i] & 0xFF)); 40 | } 41 | return row; 42 | } 43 | 44 | @Override 45 | public byte[] getMatrix() { 46 | byte[] matrix = delegate.getMatrix(); 47 | int length = getWidth() * getHeight(); 48 | byte[] invertedMatrix = new byte[length]; 49 | for (int i = 0; i < length; i++) { 50 | invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF)); 51 | } 52 | return invertedMatrix; 53 | } 54 | 55 | @Override 56 | public boolean isCropSupported() { 57 | return delegate.isCropSupported(); 58 | } 59 | 60 | @Override 61 | public LuminanceSource crop(int left, int top, int width, int height) { 62 | return new InvertedLuminanceSource(delegate.crop(left, top, width, height)); 63 | } 64 | 65 | @Override 66 | public boolean isRotateSupported() { 67 | return delegate.isRotateSupported(); 68 | } 69 | 70 | /** 71 | * @return original delegate {@link LuminanceSource} since invert undoes itself 72 | */ 73 | @Override 74 | public LuminanceSource invert() { 75 | return delegate; 76 | } 77 | 78 | @Override 79 | public LuminanceSource rotateCounterClockwise() { 80 | return new InvertedLuminanceSource(delegate.rotateCounterClockwise()); 81 | } 82 | 83 | @Override 84 | public LuminanceSource rotateCounterClockwise45() { 85 | return new InvertedLuminanceSource(delegate.rotateCounterClockwise45()); 86 | } 87 | 88 | } 89 | --------------------------------------------------------------------------------