Skip to content

Commit 3ccd476

Browse files
committed
First commit
0 parents  commit 3ccd476

190 files changed

Lines changed: 19422 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
5+
# Files for the ART/Dalvik VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# Generated files
12+
bin/
13+
gen/
14+
out/
15+
16+
# Gradle files
17+
.gradle/
18+
build/
19+
20+
# Local configuration file (sdk path, etc)
21+
local.properties
22+
23+
# Proguard folder generated by Eclipse
24+
proguard/
25+
26+
# Log Files
27+
*.log
28+
29+
# Android Studio Navigation editor temp files
30+
.navigation/
31+
32+
# Android Studio captures folder
33+
captures/
34+
35+
# IntelliJ
36+
*.iml
37+
.idea/workspace.xml
38+
.idea/tasks.xml
39+
.idea/gradle.xml
40+
.idea/assetWizardSettings.xml
41+
.idea/dictionaries
42+
.idea/libraries
43+
.idea/caches
44+
45+
# Keystore files
46+
# Uncomment the following line if you do not want to check your keystore files in.
47+
#*.jks
48+
49+
# External native build folder generated in Android Studio 2.2 and later
50+
.externalNativeBuild
51+
52+
# Google Services (e.g. APIs or Firebase)
53+
google-services.json
54+
55+
# Freeline
56+
freeline.py
57+
freeline/
58+
freeline_project_description.json
59+
60+
# fastlane
61+
fastlane/report.xml
62+
fastlane/Preview.html
63+
fastlane/screenshots
64+
fastlane/test_output
65+
fastlane/readme.md

.idea/modules.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CaptureActivity/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apply plugin: 'com.android.library'
2+
android {
3+
compileSdkVersion 7
4+
buildToolsVersion '27.0.3'
5+
6+
defaultConfig {
7+
minSdkVersion 7
8+
targetSdkVersion 7
9+
}
10+
11+
buildTypes {
12+
release {
13+
minifyEnabled false
14+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
15+
}
16+
}
17+
}
18+
19+
dependencies {
20+
compile files('libs/core.jar')
21+
}

CaptureActivity/libs/core.jar

420 KB
Binary file not shown.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2008 ZXing authors
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
package="com.google.zxing.client.android"
19+
android:versionName="4.0"
20+
android:versionCode="79">
21+
22+
<uses-permission android:name="android.permission.CAMERA"/>
23+
<uses-permission android:name="android.permission.INTERNET"/>
24+
<uses-permission android:name="android.permission.VIBRATE"/>
25+
<uses-permission android:name="android.permission.FLASHLIGHT"/>
26+
<uses-permission android:name="android.permission.READ_CONTACTS"/>
27+
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
28+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
29+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
30+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
31+
32+
<uses-sdk android:minSdkVersion="7"
33+
android:targetSdkVersion="7"/>
34+
35+
<uses-feature android:name="android.hardware.camera"/>
36+
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
37+
<uses-feature android:name="android.hardware.camera.flash" android:required="false"/>
38+
<uses-feature android:name="android.hardware.screen.landscape"/>
39+
<uses-feature android:name="android.hardware.wifi" android:required="false"/>
40+
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
41+
42+
<!-- Donut-specific flags which allow us to run on any dpi screens. -->
43+
<supports-screens android:largeScreens="true"
44+
android:normalScreens="true"
45+
android:smallScreens="true"
46+
android:anyDensity="true"/>
47+
48+
<application android:icon="@drawable/launcher_icon"
49+
android:label="@string/app_name">
50+
<activity android:name=".CaptureActivity"
51+
android:screenOrientation="landscape"
52+
android:clearTaskOnLaunch="true"
53+
android:stateNotNeeded="true"
54+
android:configChanges="orientation|keyboardHidden"
55+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
56+
android:windowSoftInputMode="stateAlwaysHidden">
57+
<intent-filter>
58+
<action android:name="android.intent.action.MAIN"/>
59+
<!--<category android:name="android.intent.category.LAUNCHER"/>-->
60+
</intent-filter>
61+
<intent-filter>
62+
<action android:name="com.google.zxing.client.android.SCAN"/>
63+
<category android:name="android.intent.category.DEFAULT"/>
64+
</intent-filter>
65+
<!-- Allow web apps to launch Barcode Scanner by linking to http://zxing.appspot.com/scan. -->
66+
<intent-filter>
67+
<action android:name="android.intent.action.VIEW"/>
68+
<category android:name="android.intent.category.DEFAULT"/>
69+
<category android:name="android.intent.category.BROWSABLE"/>
70+
<data android:scheme="http" android:host="zxing.appspot.com" android:path="/scan"/>
71+
</intent-filter>
72+
<!-- We also support a Google Product Search URL. -->
73+
<intent-filter>
74+
<action android:name="android.intent.action.VIEW"/>
75+
<category android:name="android.intent.category.DEFAULT"/>
76+
<category android:name="android.intent.category.BROWSABLE"/>
77+
<data android:scheme="http" android:host="www.google.com" android:path="/m/products/scan"/>
78+
</intent-filter>
79+
<!-- And the UK version. -->
80+
<intent-filter>
81+
<action android:name="android.intent.action.VIEW"/>
82+
<category android:name="android.intent.category.DEFAULT"/>
83+
<category android:name="android.intent.category.BROWSABLE"/>
84+
<data android:scheme="http" android:host="www.google.co.uk" android:path="/m/products/scan"/>
85+
</intent-filter>
86+
<!-- Support zxing://scan/?... like iPhone app -->
87+
<intent-filter>
88+
<action android:name="android.intent.action.VIEW"/>
89+
<category android:name="android.intent.category.DEFAULT"/>
90+
<category android:name="android.intent.category.BROWSABLE"/>
91+
<data android:scheme="zxing" android:host="scan" android:path="/"/>
92+
</intent-filter>
93+
</activity>
94+
<activity android:name=".PreferencesActivity"
95+
android:label="@string/preferences_name"
96+
android:stateNotNeeded="true">
97+
</activity>
98+
<activity android:name=".encode.EncodeActivity"
99+
android:label="@string/share_name"
100+
android:stateNotNeeded="true">
101+
<intent-filter>
102+
<action android:name="com.google.zxing.client.android.ENCODE"/>
103+
<category android:name="android.intent.category.DEFAULT"/>
104+
</intent-filter>
105+
<!-- This allows us to handle the Share button in Contacts. -->
106+
<intent-filter>
107+
<action android:name="android.intent.action.SEND"/>
108+
<category android:name="android.intent.category.DEFAULT"/>
109+
<data android:mimeType="text/x-vcard"/>
110+
</intent-filter>
111+
<!-- This allows us to handle sharing any plain text . -->
112+
<intent-filter>
113+
<action android:name="android.intent.action.SEND"/>
114+
<category android:name="android.intent.category.DEFAULT"/>
115+
<data android:mimeType="text/plain"/>
116+
</intent-filter>
117+
</activity>
118+
<activity android:name=".book.SearchBookContentsActivity"
119+
android:label="@string/sbc_name"
120+
android:stateNotNeeded="true"
121+
android:screenOrientation="landscape"
122+
android:configChanges="orientation|keyboardHidden">
123+
<intent-filter>
124+
<action android:name="com.google.zxing.client.android.SEARCH_BOOK_CONTENTS"/>
125+
<category android:name="android.intent.category.DEFAULT"/>
126+
</intent-filter>
127+
</activity>
128+
<activity android:name=".share.ShareActivity"
129+
android:label="@string/share_name"
130+
android:stateNotNeeded="true"
131+
android:screenOrientation="user"
132+
android:theme="@android:style/Theme.Light">
133+
<intent-filter>
134+
<action android:name="com.google.zxing.client.android.SHARE"/>
135+
<category android:name="android.intent.category.DEFAULT"/>
136+
</intent-filter>
137+
</activity>
138+
<activity android:name=".history.HistoryActivity"
139+
android:label="@string/history_title"
140+
android:stateNotNeeded="true">
141+
<intent-filter>
142+
<action android:name="android.intent.action.VIEW"/>
143+
<category android:name="android.intent.category.DEFAULT"/>
144+
</intent-filter>
145+
</activity>
146+
<activity android:name=".share.BookmarkPickerActivity"
147+
android:label="@string/bookmark_picker_name"
148+
android:stateNotNeeded="true">
149+
<intent-filter>
150+
<action android:name="android.intent.action.PICK"/>
151+
<category android:name="android.intent.category.DEFAULT"/>
152+
</intent-filter>
153+
</activity>
154+
<activity android:name=".share.AppPickerActivity"
155+
android:label="@string/app_picker_name"
156+
android:stateNotNeeded="true"
157+
android:configChanges="orientation">
158+
<intent-filter>
159+
<action android:name="android.intent.action.PICK"/>
160+
<category android:name="android.intent.category.DEFAULT"/>
161+
</intent-filter>
162+
</activity>
163+
<activity android:name=".HelpActivity"
164+
android:screenOrientation="user">
165+
<intent-filter>
166+
<action android:name="android.intent.action.VIEW"/>
167+
<category android:name="android.intent.category.DEFAULT"/>
168+
</intent-filter>
169+
</activity>
170+
</application>
171+
172+
</manifest>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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.Context;
21+
import android.content.SharedPreferences;
22+
import android.content.res.AssetFileDescriptor;
23+
import android.media.AudioManager;
24+
import android.media.MediaPlayer;
25+
import android.os.Vibrator;
26+
import android.preference.PreferenceManager;
27+
import android.util.Log;
28+
29+
import java.io.IOException;
30+
31+
/**
32+
* Manages beeps and vibrations for {@link CaptureActivity}.
33+
*/
34+
final class BeepManager {
35+
36+
private static final String TAG = BeepManager.class.getSimpleName();
37+
38+
private static final float BEEP_VOLUME = 0.10f;
39+
private static final long VIBRATE_DURATION = 200L;
40+
41+
private final Activity activity;
42+
private MediaPlayer mediaPlayer;
43+
private boolean playBeep;
44+
private boolean vibrate;
45+
46+
BeepManager(Activity activity) {
47+
this.activity = activity;
48+
this.mediaPlayer = null;
49+
updatePrefs();
50+
}
51+
52+
void updatePrefs() {
53+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
54+
playBeep = shouldBeep(prefs, activity);
55+
vibrate = prefs.getBoolean(PreferencesActivity.KEY_VIBRATE, false);
56+
if (playBeep && mediaPlayer == null) {
57+
// The volume on STREAM_SYSTEM is not adjustable, and users found it too loud,
58+
// so we now play on the music stream.
59+
activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
60+
mediaPlayer = buildMediaPlayer(activity);
61+
}
62+
}
63+
64+
void playBeepSoundAndVibrate() {
65+
if (playBeep && mediaPlayer != null) {
66+
mediaPlayer.start();
67+
}
68+
if (vibrate) {
69+
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
70+
vibrator.vibrate(VIBRATE_DURATION);
71+
}
72+
}
73+
74+
private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
75+
boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
76+
if (shouldPlayBeep) {
77+
// See if sound settings overrides this
78+
AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
79+
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
80+
shouldPlayBeep = false;
81+
}
82+
}
83+
return shouldPlayBeep;
84+
}
85+
86+
private static MediaPlayer buildMediaPlayer(Context activity) {
87+
MediaPlayer mediaPlayer = new MediaPlayer();
88+
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
89+
// When the beep has finished playing, rewind to queue up another one.
90+
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
91+
@Override
92+
public void onCompletion(MediaPlayer player) {
93+
player.seekTo(0);
94+
}
95+
});
96+
97+
AssetFileDescriptor file = activity.getResources().openRawResourceFd(R.raw.beep);
98+
try {
99+
mediaPlayer.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength());
100+
file.close();
101+
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
102+
mediaPlayer.prepare();
103+
} catch (IOException ioe) {
104+
Log.w(TAG, ioe);
105+
mediaPlayer = null;
106+
}
107+
return mediaPlayer;
108+
}
109+
110+
}

0 commit comments

Comments
 (0)