-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hupei
committed
Jul 1, 2016
0 parents
commit be4df7b
Showing
311 changed files
with
46,570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
.idea | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
build | ||
/captures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.1.2' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "23.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.google.zxing.client.android" | ||
minSdkVersion 15 | ||
targetSdkVersion 22 | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile project(':zxing') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2008 ZXing authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.zxing.client.android" | ||
android:installLocation="auto" | ||
android:versionCode="106" | ||
android:versionName="4.7.6" > | ||
|
||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.FLASHLIGHT" /> | ||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
<!-- unavailable in API 23 --> | ||
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
|
||
<uses-sdk | ||
android:minSdkVersion="15" | ||
android:targetSdkVersion="22" /> | ||
|
||
<!-- Don't require camera, as this requires a rear camera. This allows it to work on the Nexus 7 --> | ||
<uses-feature | ||
android:name="android.hardware.camera" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.hardware.camera.front" | ||
android:required="false" /> | ||
<!-- TODO replace above two with next line after Android 4.2 --> | ||
<!-- <uses-feature android:name="android.hardware.camera.any"/> --> | ||
<uses-feature | ||
android:name="android.hardware.camera.autofocus" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.hardware.camera.flash" | ||
android:required="false" /> | ||
<uses-feature android:name="android.hardware.screen.landscape" /> | ||
<uses-feature | ||
android:name="android.hardware.wifi" | ||
android:required="false" /> | ||
<!-- This excludes Google TV, which is unfortunately included by virtue of not requiring a camera --> | ||
<uses-feature android:name="android.hardware.touchscreen" /> | ||
<!-- TODO make this not required again after android.hardware.camera.any is available --> | ||
|
||
<supports-screens | ||
android:anyDensity="true" | ||
android:largeScreens="true" | ||
android:normalScreens="true" | ||
android:smallScreens="true" | ||
android:xlargeScreens="true" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/launcher_icon" | ||
android:label="@string/app_name" | ||
android:logo="@drawable/launcher_icon" > | ||
<activity | ||
android:name=".CaptureActivity" | ||
android:clearTaskOnLaunch="true" | ||
android:screenOrientation="portrait" | ||
android:stateNotNeeded="true" | ||
android:theme="@style/CaptureTheme" | ||
android:windowSoftInputMode="stateAlwaysHidden" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="com.google.zxing.client.android.SCAN" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
<!-- Allow web apps to launch Barcode Scanner by linking to http://zxing.appspot.com/scan. --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data | ||
android:host="zxing.appspot.com" | ||
android:path="/scan" | ||
android:scheme="http" /> | ||
</intent-filter> | ||
<!-- We also support a Google Product Search URL. --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data | ||
android:host="www.google.com" | ||
android:path="/m/products/scan" | ||
android:scheme="http" /> | ||
</intent-filter> | ||
<!-- And the UK version. --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data | ||
android:host="www.google.co.uk" | ||
android:path="/m/products/scan" | ||
android:scheme="http" /> | ||
</intent-filter> | ||
<!-- Support zxing://scan/?... like iPhone app --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data | ||
android:host="scan" | ||
android:path="/" | ||
android:scheme="zxing" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
89 changes: 89 additions & 0 deletions
89
captureActivity/src/main/java/com/google/zxing/client/android/AmbientLightManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (C) 2012 ZXing authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.zxing.client.android; | ||
|
||
import android.content.Context; | ||
import android.hardware.Sensor; | ||
import android.hardware.SensorEvent; | ||
import android.hardware.SensorEventListener; | ||
import android.hardware.SensorManager; | ||
|
||
import com.google.zxing.client.android.camera.CameraManager; | ||
import com.google.zxing.client.android.camera.FrontLightMode; | ||
|
||
/** | ||
* Detects ambient light and switches on the front light when very dark, and off | ||
* again when sufficiently light. | ||
* | ||
* @author Sean Owen | ||
* @author Nikolaus Huber | ||
*/ | ||
final class AmbientLightManager implements SensorEventListener { | ||
|
||
private static final float TOO_DARK_LUX = 45.0f; | ||
private static final float BRIGHT_ENOUGH_LUX = 450.0f; | ||
|
||
private final Context context; | ||
private CameraManager cameraManager; | ||
private Sensor lightSensor; | ||
|
||
AmbientLightManager(Context context) { | ||
this.context = context; | ||
} | ||
|
||
void start(CameraManager cameraManager) { | ||
this.cameraManager = cameraManager; | ||
// 不开闪光灯 | ||
if (FrontLightMode.OFF == FrontLightMode.AUTO) { | ||
SensorManager sensorManager = (SensorManager) context | ||
.getSystemService(Context.SENSOR_SERVICE); | ||
lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); | ||
if (lightSensor != null) { | ||
sensorManager.registerListener(this, lightSensor, | ||
SensorManager.SENSOR_DELAY_NORMAL); | ||
} | ||
} | ||
} | ||
|
||
void stop() { | ||
if (lightSensor != null) { | ||
SensorManager sensorManager = (SensorManager) context | ||
.getSystemService(Context.SENSOR_SERVICE); | ||
sensorManager.unregisterListener(this); | ||
cameraManager = null; | ||
lightSensor = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void onSensorChanged(SensorEvent sensorEvent) { | ||
float ambientLightLux = sensorEvent.values[0]; | ||
if (cameraManager != null) { | ||
if (ambientLightLux <= TOO_DARK_LUX) { | ||
cameraManager.setTorch(true); | ||
} else if (ambientLightLux >= BRIGHT_ENOUGH_LUX) { | ||
cameraManager.setTorch(false); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onAccuracyChanged(Sensor sensor, int accuracy) { | ||
// do nothing | ||
} | ||
|
||
} |
Oops, something went wrong.