Commit 135ed4bef681d6c9d326ca16813c57e86406da77

Authored by YangShuai
1 parent 0011be9e

1 新增电商

Showing 52 changed files with 189 additions and 2895 deletions
app/strike/src/main/AndroidManifest.xml
... ... @@ -17,6 +17,18 @@
17 17 android:roundIcon="@mipmap/ic_launcher_round"
18 18 android:supportsRtl="true"
19 19 android:theme="@style/AppTheme">
  20 + <provider
  21 + android:name="androidx.core.content.FileProvider"
  22 + android:authorities="${applicationId}.fileprovider"
  23 + android:exported="false"
  24 + android:grantUriPermissions="true"
  25 + tools:replace="android:authorities">
  26 + <meta-data
  27 + android:name="android.support.FILE_PROVIDER_PATHS"
  28 + android:resource="@xml/app_files"
  29 + tools:replace="android:resource" />
  30 + </provider>
  31 +
20 32 <activity android:name="com.cnlive.strike.demo.activity.CNplayerActivity" />
21 33 <activity android:name="com.cnlive.strike.demo.activity.DemoAnimActivity" />
22 34 <activity
... ... @@ -37,6 +49,7 @@
37 49  
38 50 <meta-data
39 51 android:name="com.baidu.lbsapi.API_KEY"
  52 + tools:replace="android:value"
40 53 android:value="${BAIDU_MAP_APP_KEY}" />
41 54 <meta-data
42 55 android:name="com.baidu.speech.APP_ID"
... ...
app/strike/src/main/java/com/cnlive/strike/MyApp.java
... ... @@ -29,6 +29,8 @@ public class MyApp extends BaseApplication {
29 29 //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
30 30 //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
31 31 SDKInitializer.setCoordType(CoordType.GCJ02);
  32 + //初始化上海电商
  33 + cn.cnlive.b2c.AppApplication.initSDK(this);
32 34 }
33 35  
34 36  
... ...
app/strike/src/main/java/com/cnlive/strike/demo/activity/CNplayerActivity.java
... ... @@ -57,7 +57,7 @@ public class CNplayerActivity extends BaseActivity implements IMediaPlayer.OnPre
57 57 QMUITipDialogUtil.loadingDialog(me,"直播");
58 58 // binding.videoview.setDataSource(new DataSource("604_233216be9552476b93d2c0cac7819222", Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2));
59 59 // binding.videoview.setDataSource(new DataSource("223_b66053d9eaf147efa58eb1ae4b47661e", Config.TYPE_VOD, Config.TYPE_PLAY_RATE_2));
60   - binding.videoview.setDataSource(new DataSource("604_75ca27cce3a043b1876f694dd1125234", Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2));
  60 + binding.videoview.setDataSource(new DataSource("604_maishicaijing", Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2));
61 61  
62 62 }
63 63 binding.videoview.start();
... ...
app/strike/src/main/java/com/cnlive/strike/demo/activity/DemoMvpActivity.java
... ... @@ -5,10 +5,7 @@ import android.content.Intent;
5 5 import android.os.Handler;
6 6 import android.os.Message;
7 7 import android.text.TextUtils;
8   -import android.view.LayoutInflater;
9 8 import android.view.View;
10   -import android.widget.LinearLayout;
11   -import android.widget.TextView;
12 9  
13 10 import androidx.annotation.NonNull;
14 11 import androidx.databinding.ViewDataBinding;
... ... @@ -23,8 +20,10 @@ import com.cnlive.cloud.user.ui.activity.PersonalDataActivity;
23 20 import com.cnlive.cloud.wjjpay.pay.WjjPay;
24 21 import com.cnlive.cloud.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo;
25 22 import com.cnlive.cloud.xiaojiaspeaker.ui.activity.AllDeviceActivity;
  23 +import com.cnlive.core.libs.base.arouter.user.CNLiveUserService;
26 24 import com.cnlive.core.libs.base.frame.activity.BaseActivity;
27 25 import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  26 +import com.cnlive.core.libs.base.util.OpenServiceHelpUtil;
28 27 import com.cnlive.core.libs.base.util.QMUITipDialogUtil;
29 28 import com.cnlive.core.libs.base.util.StatusBarConfig;
30 29 import com.cnlive.core.network.HttpConn;
... ... @@ -33,7 +32,6 @@ import com.cnlive.core.network.model.BaseResult;
33 32 import com.cnlive.core.network.request.BaseRequest;
34 33 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
35 34 import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity;
36   -import com.cnlive.strike.MyApp;
37 35 import com.cnlive.strike.demo.activity.presenter.DemoActivityPresenter;
38 36 import com.cnlive.strike.demo.activity.view.DemoActivityView;
39 37 import com.cnlive.strike.network.api.ApiService;
... ... @@ -403,6 +401,24 @@ public class DemoMvpActivity extends BaseActivity&lt;DemoActivityView, DemoActivity
403 401 intent.putExtra("type","1");
404 402 startActivity(intent); }
405 403 });
  404 + //获取uid
  405 + binding.btnUid.setOnClickListener(new View.OnClickListener() {
  406 + @Override
  407 + public void onClick(View v) {
  408 + CNLiveUserService userService= OpenServiceHelpUtil.getUserService(me);
  409 + if (null!=userService){
  410 + QMUITipDialogUtil.textDialog(me,userService.getUid(me));
  411 + }
  412 + }
  413 + });
  414 + //上海电商
  415 + binding.btnShanghai.setOnClickListener(new View.OnClickListener() {
  416 + @Override
  417 + public void onClick(View v) {
  418 +// Intent intent = new Intent(me, cn.cnlive.b2c.MainActivity.class);
  419 +// startActivity(intent);
  420 + }
  421 + });
406 422  
407 423 }
408 424  
... ...
app/strike/src/main/res/layout/activity_demo_mvp_main.xml
... ... @@ -91,6 +91,18 @@
91 91 android:layout_height="wrap_content"
92 92 android:layout_margin="5dp"
93 93 android:text="动画特效" />
  94 + <Button
  95 + android:id="@+id/btn_shanghai"
  96 + android:layout_width="match_parent"
  97 + android:layout_height="wrap_content"
  98 + android:layout_margin="5dp"
  99 + android:text="上海电商" />
  100 + <Button
  101 + android:id="@+id/btn_uid"
  102 + android:layout_width="match_parent"
  103 + android:layout_height="wrap_content"
  104 + android:layout_margin="5dp"
  105 + android:text="ARouter获取uid" />
94 106  
95 107 <Button
96 108 android:id="@+id/btn_cnPlayer"
... ... @@ -98,12 +110,14 @@
98 110 android:layout_height="wrap_content"
99 111 android:layout_margin="5dp"
100 112 android:text="点播" />
  113 +
101 114 <Button
102 115 android:id="@+id/btn_livePlayer"
103 116 android:layout_width="match_parent"
104 117 android:layout_height="wrap_content"
105 118 android:layout_margin="5dp"
106 119 android:text="直播" />
  120 +
107 121 <Button
108 122 android:id="@+id/btn_pay"
109 123 android:layout_width="match_parent"
... ...
app/strike/src/main/res/layout/activity_img.xml
1 1 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:lb="http://schemas.android.com/apk/res-auto"
2 3 android:layout_width="match_parent"
3   - android:layout_height="match_parent"
4   - xmlns:lb="http://schemas.android.com/apk/res-auto">
  4 + android:layout_height="match_parent">
5 5  
6 6 <LinearLayout
7 7 android:layout_width="match_parent"
... ... @@ -11,40 +11,41 @@
11 11 <TextView
12 12 android:layout_width="wrap_content"
13 13 android:layout_height="wrap_content"
14   - android:text="加载动效自定义:"
15   - />
  14 + android:text="加载动效自定义:" />
  15 +
16 16 <ImageView
17 17 android:id="@+id/iv_test1"
18 18 android:layout_width="300dp"
19 19 android:layout_height="300dp"
20 20 android:padding="10dp" />
  21 +
21 22 <TextView
22 23 android:layout_width="wrap_content"
23 24 android:layout_height="wrap_content"
24   - android:text="放大缩小:"
25   - />
26   - <ImageView
27   - android:id="@+id/iv_test2"
28   - android:layout_width="200dp"
29   - android:layout_height="200dp"
30   - android:padding="10dp" />
  25 + android:text="放大缩小:" />
  26 +
  27 + <ImageView
  28 + android:id="@+id/iv_test2"
  29 + android:layout_width="200dp"
  30 + android:layout_height="200dp"
  31 + android:padding="10dp" />
31 32  
32 33 <TextView
33 34 android:layout_width="wrap_content"
34 35 android:layout_height="wrap_content"
35   - android:text="网络gif:"
36   - />
  36 + android:text="网络gif:" />
37 37  
38 38 <ImageView
39 39 android:id="@+id/iv_test3"
40 40 android:layout_width="300dp"
41 41 android:layout_height="300dp"
42 42 android:padding="10dp" />
  43 +
43 44 <TextView
44 45 android:layout_width="wrap_content"
45 46 android:layout_height="wrap_content"
46   - android:text="mipmap下的gif:"
47   - />
  47 + android:text="mipmap下的gif:" />
  48 +
48 49 <ImageView
49 50 android:id="@+id/iv_test4"
50 51 android:layout_width="300dp"
... ... @@ -54,8 +55,8 @@
54 55 <TextView
55 56 android:layout_width="wrap_content"
56 57 android:layout_height="wrap_content"
57   - android:text="mipmap下的图片:"
58   - />
  58 + android:text="mipmap下的图片:" />
  59 +
59 60 <ImageView
60 61 android:id="@+id/iv_test5"
61 62 android:layout_width="300dp"
... ... @@ -65,8 +66,8 @@
65 66 <TextView
66 67 android:layout_width="wrap_content"
67 68 android:layout_height="wrap_content"
68   - android:text="滤镜优先级设置"
69   - />
  69 + android:text="滤镜优先级设置" />
  70 +
70 71 <ImageView
71 72 android:id="@+id/iv_test6"
72 73 android:layout_width="300dp"
... ... @@ -76,8 +77,8 @@
76 77 <TextView
77 78 android:layout_width="wrap_content"
78 79 android:layout_height="wrap_content"
79   - android:text="素描"
80   - />
  80 + android:text="素描" />
  81 +
81 82 <ImageView
82 83 android:id="@+id/iv_test7"
83 84 android:layout_width="300dp"
... ... @@ -87,8 +88,7 @@
87 88 <TextView
88 89 android:layout_width="wrap_content"
89 90 android:layout_height="wrap_content"
90   - android:text="加载asserts下面的图片"
91   - />
  91 + android:text="加载asserts下面的图片" />
92 92  
93 93 <ImageView
94 94 android:id="@+id/iv_test8"
... ... @@ -99,8 +99,8 @@
99 99 <TextView
100 100 android:layout_width="wrap_content"
101 101 android:layout_height="wrap_content"
102   - android:text="加载raw下面的图片为圆"
103   - />
  102 + android:text="加载raw下面的图片为圆" />
  103 +
104 104 <ImageView
105 105 android:id="@+id/iv_test9"
106 106 android:layout_width="300dp"
... ... @@ -110,8 +110,8 @@
110 110 <TextView
111 111 android:layout_width="wrap_content"
112 112 android:layout_height="wrap_content"
113   - android:text="图片设置圆角"
114   - />
  113 + android:text="图片设置圆角" />
  114 +
115 115 <ImageView
116 116 android:id="@+id/iv_test10"
117 117 android:layout_width="300dp"
... ... @@ -121,13 +121,13 @@
121 121 <TextView
122 122 android:layout_width="wrap_content"
123 123 android:layout_height="wrap_content"
124   - android:text="图片下载显示"
125   - />
  124 + android:text="图片下载显示" />
  125 +
126 126 <Button
127 127 android:id="@+id/down"
128 128 android:layout_width="wrap_content"
129 129 android:layout_height="wrap_content"
130   - android:text="下载"/>
  130 + android:text="下载" />
131 131  
132 132 <ImageView
133 133 android:id="@+id/iv_test11"
... ... @@ -138,45 +138,42 @@
138 138 <TextView
139 139 android:layout_width="wrap_content"
140 140 android:layout_height="wrap_content"
141   - android:text="直接代码设置,五边形"/>
  141 + android:text="直接代码设置,五边形" />
142 142  
143 143 <com.cnlive.core.imageload.util.MultiView
144 144 android:layout_width="300dp"
145 145 android:layout_height="300dp"
146 146 android:layout_margin="30dp"
147   - lb:angleCount="5"
148   - lb:type="multi"
149 147 android:src="@mipmap/timgs"
150   - />
  148 + lb:angleCount="5"
  149 + lb:shapeType="polygon" />
151 150  
152 151 <TextView
153 152 android:layout_width="wrap_content"
154 153 android:layout_height="wrap_content"
155   - android:text="直接代码设置,设置圆角"/>
  154 + android:text="直接代码设置,设置圆角" />
156 155  
157 156 <com.cnlive.core.imageload.util.MultiView
158 157 android:layout_width="200dp"
159 158 android:layout_height="200dp"
160   - android:layout_margin="30dp"
161 159 android:layout_gravity="center"
162   - lb:borderRadius="10dp"
163   - lb:type="round"
  160 + android:layout_margin="30dp"
164 161 android:src="@mipmap/timgs"
165   - />
  162 + lb:borderRadius="10dp"
  163 + lb:shapeType="round" />
166 164  
167 165 <TextView
168 166 android:layout_width="wrap_content"
169 167 android:layout_height="wrap_content"
170   - android:text="直接代码设置圆"/>
  168 + android:text="直接代码设置圆" />
171 169  
172 170 <com.cnlive.core.imageload.util.MultiView
173   - android:layout_margin="30dp"
174 171 android:layout_width="200dp"
175 172 android:layout_height="200dp"
176 173 android:layout_gravity="center"
  174 + android:layout_margin="30dp"
177 175 android:src="@mipmap/timgs"
178   - lb:type="circle"
179   - />
  176 + lb:type="circle" />
180 177  
181 178 </LinearLayout>
182 179 </ScrollView>
... ...
app/strike/src/main/res/xml/app_files.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <paths>
  4 + <external-path
  5 + name="external_files"
  6 + path="" />
  7 +
  8 + <path>
  9 + <root-path
  10 + name="root_path"
  11 + path="." />
  12 + </path>
  13 +
  14 + </paths>
  15 +</resources>
0 16 \ No newline at end of file
... ...
build.gradle
... ... @@ -27,6 +27,12 @@ allprojects {
27 27 // configurations.all {
28 28 ////// resolutionStrategy.force 'androidx.appcompat:appcompat:1.1.0'
29 29 // }
  30 + //添加java编译指令,防止引用时,形参变成var1
  31 + gradle.projectsEvaluated {
  32 + tasks.withType(JavaCompile) {
  33 + options.compilerArgs.add('-parameters')
  34 + }
  35 + }
30 36 afterEvaluate {
31 37 if (project.parent == null || project.parent == rootProject) return
32 38  
... ... @@ -129,6 +135,10 @@ allprojects {
129 135 url maven.mixedUrl
130 136 credentials { username = nexusId; password = nexusPw }
131 137 }
  138 + maven {
  139 + url 'http://android.nexus.cnlive.com/repository/cnlive-shop/'
  140 + credentials { username = 'shop'; password = 'ShangHa1' }
  141 + }
132 142 //------------------ 资源库配置 END------------------
133 143 maven { url 'https://dl.bintray.com/umsdk/release' }
134 144 //关联微博
... ... @@ -139,6 +149,7 @@ allprojects {
139 149 maven {
140 150 url 'https://dl.bintray.com/granzon/cnliveLibs'
141 151 }
  152 +
142 153 maven {
143 154 url "https://jitpack.io"
144 155 }
... ...
cloud/user/src/main/java/com/cnlive/cloud/user/router/user/CNLiveUserServiceImpl.java
... ... @@ -6,6 +6,7 @@ import android.text.TextUtils;
6 6 import com.alibaba.android.arouter.facade.annotation.Route;
7 7 import com.alibaba.android.arouter.launcher.ARouter;
8 8 import com.cnlive.cloud.user.auth.UserService;
  9 +import com.cnlive.core.libs.base.arouter.RouterConst;
9 10 import com.cnlive.core.libs.base.arouter.user.CNLiveUserService;
10 11 import com.cnlive.core.libs.base.arouter.user.OpenUserInfo;
11 12  
... ... @@ -14,7 +15,7 @@ import com.cnlive.core.libs.base.arouter.user.OpenUserInfo;
14 15 *
15 16 * @author ys
16 17 */
17   -@Route(path = CNLiveUserService.PATH, name = CNLiveUserService.NAME)
  18 +@Route(path = RouterConst.OPEN_USER_SERVICE_PATH, name = RouterConst.OPEN_USER_SERVICE_NAME)
18 19 public class CNLiveUserServiceImpl implements CNLiveUserService {
19 20  
20 21 @Override
... ...
core/base/src/main/java/com/cnlive/core/libs/base/application/MyAppGlideModule.java
1 1 package com.cnlive.core.libs.base.application;
2 2  
  3 +import android.content.Context;
  4 +
  5 +import androidx.annotation.NonNull;
  6 +
  7 +import com.bumptech.glide.GlideBuilder;
3 8 import com.bumptech.glide.annotation.GlideModule;
4 9 import com.bumptech.glide.module.AppGlideModule;
5 10  
... ... @@ -9,5 +14,8 @@ import com.bumptech.glide.module.AppGlideModule;
9 14  
10 15 @GlideModule
11 16 public final class MyAppGlideModule extends AppGlideModule {
12   -
  17 + @Override
  18 + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
  19 + super.applyOptions(context, builder);
  20 + }
13 21 }
... ...
core/base/src/main/java/com/cnlive/core/libs/base/arouter/RouterConst.java
1 1 package com.cnlive.core.libs.base.arouter;
2 2  
3 3 public class RouterConst {
  4 + //获取用户信息
4 5 public static final String OPEN_USER_SERVICE_PATH = "/Common/UserInfoService";
5 6 public static final String OPEN_USER_SERVICE_NAME = "UserInfoService";
6 7  
... ...
core/base/src/main/java/com/cnlive/core/libs/base/arouter/user/CNLiveUserService.java
... ... @@ -8,9 +8,6 @@ import com.alibaba.android.arouter.facade.template.IProvider;
8 8 * 给上海电商 用户库
9 9 */
10 10 public interface CNLiveUserService extends IProvider {
11   - public static final String PATH = "/openService/CNLiveUserService";
12   - public static final String NAME = "开放用户信息的服务接口";
13   -
14 11 /**
15 12 * 跳转到登录页
16 13 *
... ...
core/base/src/main/java/com/cnlive/core/libs/base/util/OpenServiceHelpUtil.java 0 → 100644
  1 +package com.cnlive.core.libs.base.util;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.alibaba.android.arouter.launcher.ARouter;
  6 +import com.cnlive.core.libs.base.arouter.RouterConst;
  7 +import com.cnlive.core.libs.base.arouter.user.CNLiveUserService;
  8 +
  9 +public class OpenServiceHelpUtil {
  10 + /**
  11 + * 获取用户库
  12 + *
  13 + * @param context
  14 + * @return
  15 + */
  16 + public static CNLiveUserService getUserService(Context context) {
  17 + CNLiveUserService cnLiveUserService = null;
  18 + cnLiveUserService = (CNLiveUserService) ARouter.getInstance().build(RouterConst.OPEN_USER_SERVICE_PATH).navigation(context);
  19 + return cnLiveUserService;
  20 + }
  21 +
  22 +// /**
  23 +// * 获取支付库
  24 +// *
  25 +// * @param context
  26 +// * @return
  27 +// */
  28 +// public static CNLivePayService getPayService(Context context) {
  29 +// CNLivePayService cnLivePayService = null;
  30 +// cnLivePayService = (CNLivePayService) ARouter.getInstance().build(CNLivePayService.PATH).navigation(context);
  31 +// return cnLivePayService;
  32 +// }
  33 +//
  34 +// /**
  35 +// * 获取分享库
  36 +// *
  37 +// * @param context
  38 +// * @return
  39 +// */
  40 +// public static CNLiveShareService getShareService(Context context) {
  41 +// CNLiveShareService cnLiveShareService = null;
  42 +// cnLiveShareService = (CNLiveShareService) ARouter.getInstance().build(CNLiveShareService.PATH).navigation(context);
  43 +// return cnLiveShareService;
  44 +// }
  45 +}
... ...
core/imageload/src/main/java/com/cnlive/core/imageload/util/MultiView.java
1 1 package com.cnlive.core.imageload.util;
2 2  
3   -import android.annotation.SuppressLint;
4 3 import android.content.Context;
5 4 import android.content.res.TypedArray;
6 5 import android.graphics.Bitmap;
... ... @@ -158,7 +157,7 @@ public class MultiView extends ImageView {
158 157 .applyDimension(TypedValue.COMPLEX_UNIT_DIP,
159 158 BODER_RADIUS_DEFAULT, getResources()
160 159 .getDisplayMetrics()));// 默认为10dp
161   - type = typedArray.getInt(R.styleable.RoundImageView_type, TYPE_CIRCLE);// 默认为Circle
  160 + type = typedArray.getInt(R.styleable.RoundImageView_shapeType, TYPE_CIRCLE);// 默认为Circle
162 161 angleCount = typedArray.getInt(R.styleable.RoundImageView_angleCount, ANGLECOUNT);
163 162 currentAngle = typedArray.getInt(R.styleable.RoundImageView_currentAngle, currentAngle);
164 163  
... ...
core/imageload/src/main/res/values/style.xml
... ... @@ -2,10 +2,10 @@
2 2 <resources>
3 3 <declare-styleable name="RoundImageView">
4 4 <attr name="borderRadius" format="dimension" />
5   - <attr name="type">
  5 + <attr name="shapeType">
6 6 <enum name="circle" value="0" />
7 7 <enum name="round" value="1" />
8   - <enum name="multi" value="3" />
  8 + <enum name="polygon" value="3" />
9 9 </attr>
10 10 <attr name="angleCount" format="integer" />
11 11 <attr name="currentAngle" format="integer" />
... ...
module/shanghaishop/build.gradle
... ... @@ -18,6 +18,13 @@ dependencies {
18 18 androidTestImplementation 'androidx.test.ext:junit:1.1.1'
19 19 androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
20 20  
  21 + api('cn.cnlive.b2c:cnliveb2c:1.0.0-20191212.082956-16') {
  22 + exclude group: 'com.bumptech.glide'
  23 + }
  24 + api 'cn.cnlive.b2c:nicevideoplayer:1.0.0-20191206.090854-2'
  25 + api 'cn.cnlive.b2c:udesk-sdk-ui:1.0.0'
  26 +
  27 +
21 28 /** 圆形图片处理 androidx **/
22 29 implementation 'de.hdodenhof:circleimageview:3.0.1'
23 30  
... ... @@ -49,7 +56,7 @@ dependencies {
49 56 implementation 'com.songhang:smart-headerfooter-recyclerview:1.0.1'
50 57  
51 58 /*二维码*/
52   - implementation 'com.google.zxing:core:3.3.0'
  59 +// implementation 'com.google.zxing:core:3.3.0'
53 60  
54 61 // implementation ('cn.yipianfengye.android:zxing-library:2.2'){
55 62 // // 如果已经引入 support:appcompat-v7 可以加上这句话
... ... @@ -69,12 +76,12 @@ dependencies {
69 76 /*一个Android TabLayout库*/
70 77 implementation 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
71 78  
72   - /*应用卡顿检测*/
73   - debugImplementation 'com.github.markzhai:blockcanary-android:1.5.0'
74   - releaseImplementation 'com.github.markzhai:blockcanary-no-op:1.5.0'
  79 +// /*应用卡顿检测*/
  80 +// debugImplementation 'com.github.markzhai:blockcanary-android:1.5.0'
  81 +// releaseImplementation 'com.github.markzhai:blockcanary-no-op:1.5.0'
75 82  
76   - /*友盟统计*/
77   - implementation 'com.umeng.analytics:analytics:latest.integration'
  83 +// /*友盟统计*/
  84 +// implementation 'com.umeng.analytics:analytics:latest.integration'
78 85  
79 86 /*Float Labeled EditText*/
80 87 implementation 'com.wrapp.floatlabelededittext:library:0.0.6'
... ... @@ -88,29 +95,5 @@ dependencies {
88 95 /*自定义各种形状的imageview */
89 96 implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
90 97  
91   - // compile 'com.android.support:appcompat-v7:23.4.0'
92   -
93   - // compile 'com.android.support:recyclerview-v7:23.4.0'
94   -
95   - // compile 'com.android.support:design:23.4.0'
96   - implementation files('libs/alipaySingle-20161222.jar')
97   -// implementation files('libs/BaiduLBS_Android.jar')
98   - implementation files('libs/bankabccaller.jar')
99   - implementation files('libs/EhkingSDK-v2.0.jar')
100   - implementation files('libs/jackson-all-1.9.11.jar')
101   - implementation files('libs/MagicWindowSDK.jar')
102   - implementation files('libs/mqqopenpay.jar')
103   - implementation files('libs/SecurityEnvSDK-release-1.1.0.jar')
104   - implementation files('libs/umeng-common-1.5.3.jar')
105   - implementation files('libs/umeng-share-core-6.9.2.jar')
106   -// implementation files('libs/umeng-share-QQ-simplify-6.9.2.jar')
107   -// implementation files('libs/umeng-share-sina-simplify-6.9.2.jar')
108   -// implementation files('libs/umeng-share-wechat-simplify-6.9.2.jar')
109   -// implementation files('libs/umeng-share-sina-simplify-6.9.2.jar')
110   - implementation files('libs/umeng-shareboard-widget-6.9.2.jar')
111   - implementation files('libs/umeng-sharetool-6.9.2.jar')
112   - implementation files('libs/UPPayAssistEx.jar')
113   - implementation files('libs/UPPayPluginExPro.jar')
114   -
115 98  
116 99 }
... ...
module/shanghaishop/libs/EhkingSDK-v2.0.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/MagicWindowSDK.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/SecurityEnvSDK-release-1.1.0.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/UPPayAssistEx.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/UPPayPluginExPro.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/alipaySingle-20161222.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/bankabccaller.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/jackson-all-1.9.11.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/mqqopenpay.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/umeng-common-1.5.3.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/umeng-share-core-6.9.2.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/umeng-shareboard-widget-6.9.2.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/libs/umeng-sharetool-6.9.2.jar deleted 100644 → 0
No preview for this file type
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/DisplayUtil.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing;
2   -
3   -import android.content.Context;
4   -
5   -/**
6   - * Created by aaron on 16/8/3.
7   - */
8   -public class DisplayUtil
9   -{
10   -
11   - public static int screenWidthPx; //屏幕宽 px
12   - public static int screenhightPx; //屏幕高 px
13   - public static float density;//屏幕密度
14   - public static int densityDPI;//屏幕密度
15   - public static float screenWidthDip;// dp单位
16   - public static float screenHightDip;// dp单位
17   -
18   -
19   -
20   - /**
21   - * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
22   - */
23   - public static int dip2px(Context context, float dpValue) {
24   - final float scale = context.getResources().getDisplayMetrics().density;
25   - return (int) (dpValue * scale + 0.5f);
26   - }
27   -
28   - /**
29   - * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
30   - */
31   - public static int px2dip(Context context, float pxValue) {
32   - final float scale = context.getResources().getDisplayMetrics().density;
33   - return (int) (pxValue / scale + 0.5f);
34   - }
35   -
36   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/ZApplication.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing;
2   -
3   -import android.app.Application;
4   -import android.util.DisplayMetrics;
5   -
6   -/**
7   - * Created by aaron on 16/8/9.
8   - */
9   -
10   -public class ZApplication extends Application {
11   -
12   - @Override
13   - public void onCreate() {
14   - super.onCreate();
15   - /**
16   - * 初始化尺寸工具类
17   - */
18   - initDisplayOpinion();
19   - }
20   -
21   - private void initDisplayOpinion() {
22   - DisplayMetrics dm = getResources().getDisplayMetrics();
23   - DisplayUtil.density = dm.density;
24   - DisplayUtil.densityDPI = dm.densityDpi;
25   - DisplayUtil.screenWidthPx = dm.widthPixels;
26   - DisplayUtil.screenhightPx = dm.heightPixels;
27   - DisplayUtil.screenWidthDip = DisplayUtil.px2dip(getApplicationContext(), dm.widthPixels);
28   - DisplayUtil.screenHightDip = DisplayUtil.px2dip(getApplicationContext(), dm.heightPixels);
29   - }
30   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/activity/CaptureActivity.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.activity;
2   -
3   -import android.content.Intent;
4   -import android.graphics.Bitmap;
5   -import android.os.Bundle;
6   -import android.util.Log;
7   -
8   -import androidx.appcompat.app.AppCompatActivity;
9   -
10   -import com.cnlive.cloud.shanghaishop.R;
11   -
12   -
13   -/**
14   - * Initial the camera
15   - * <p>
16   - * 默认的二维码扫描Activity
17   - */
18   -public class CaptureActivity extends AppCompatActivity {
19   -
20   -
21   - @Override
22   - protected void onCreate(Bundle savedInstanceState) {
23   -
24   - super.onCreate(savedInstanceState);
25   - setContentView(R.layout.camera);
26   - CaptureFragment captureFragment = new CaptureFragment();
27   - captureFragment.setAnalyzeCallback(analyzeCallback);
28   - getSupportFragmentManager().beginTransaction().replace(R.id.fl_zxing_container, captureFragment).commit();
29   - captureFragment.setCameraInitCallBack(new CaptureFragment.CameraInitCallBack() {
30   - @Override
31   - public void callBack(Exception e) {
32   - if (e == null) {
33   -
34   - } else {
35   - Log.e("TAG", "callBack: ", e);
36   - }
37   - }
38   - });
39   -
40   - }
41   -
42   - /**
43   - * 二维码解析回调函数
44   - */
45   - CodeUtils.AnalyzeCallback analyzeCallback = new CodeUtils.AnalyzeCallback() {
46   - @Override
47   - public void onAnalyzeSuccess(Bitmap mBitmap, String result) {
48   - Intent resultIntent = new Intent();
49   - Bundle bundle = new Bundle();
50   - bundle.putInt(CodeUtils.RESULT_TYPE, CodeUtils.RESULT_SUCCESS);
51   - bundle.putString(CodeUtils.RESULT_STRING, result);
52   - resultIntent.putExtras(bundle);
53   - CaptureActivity.this.setResult(RESULT_OK, resultIntent);
54   - CaptureActivity.this.finish();
55   - }
56   -
57   - @Override
58   - public void onAnalyzeFailed() {
59   - Intent resultIntent = new Intent();
60   - Bundle bundle = new Bundle();
61   - bundle.putInt(CodeUtils.RESULT_TYPE, CodeUtils.RESULT_FAILED);
62   - bundle.putString(CodeUtils.RESULT_STRING, "");
63   - resultIntent.putExtras(bundle);
64   - CaptureActivity.this.setResult(RESULT_OK, resultIntent);
65   - CaptureActivity.this.finish();
66   - }
67   - };
68   -}
69 0 \ No newline at end of file
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/activity/CaptureFragment.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.activity;
2   -
3   -import android.content.res.AssetFileDescriptor;
4   -import android.graphics.Bitmap;
5   -import android.hardware.Camera;
6   -import android.media.AudioManager;
7   -import android.media.MediaPlayer;
8   -import android.os.Bundle;
9   -import android.os.Handler;
10   -import android.os.Vibrator;
11   -import android.text.TextUtils;
12   -import android.view.LayoutInflater;
13   -import android.view.SurfaceHolder;
14   -import android.view.SurfaceView;
15   -import android.view.View;
16   -import android.view.ViewGroup;
17   -
18   -import androidx.annotation.Nullable;
19   -import androidx.fragment.app.Fragment;
20   -
21   -import com.cnlive.cloud.shanghaishop.R;
22   -import com.google.zxing.BarcodeFormat;
23   -import com.google.zxing.Result;
24   -import com.uuzuche.lib_zxing.camera.CameraManager;
25   -import com.uuzuche.lib_zxing.decoding.CaptureActivityHandler;
26   -import com.uuzuche.lib_zxing.decoding.InactivityTimer;
27   -import com.uuzuche.lib_zxing.view.ViewfinderView;
28   -
29   -import java.io.IOException;
30   -import java.util.Vector;
31   -
32   -/**
33   - * 自定义实现的扫描Fragment
34   - */
35   -public class CaptureFragment extends Fragment implements SurfaceHolder.Callback {
36   -
37   - private CaptureActivityHandler handler;
38   - private ViewfinderView viewfinderView;
39   - private boolean hasSurface;
40   - private Vector<BarcodeFormat> decodeFormats;
41   - private String characterSet;
42   - private InactivityTimer inactivityTimer;
43   - private MediaPlayer mediaPlayer;
44   - private boolean playBeep;
45   - private static final float BEEP_VOLUME = 0.10f;
46   - private boolean vibrate;
47   - private SurfaceView surfaceView;
48   - private SurfaceHolder surfaceHolder;
49   - private CodeUtils.AnalyzeCallback analyzeCallback;
50   - private Camera camera;
51   -
52   - @Override
53   - public void onCreate(@Nullable Bundle savedInstanceState) {
54   - super.onCreate(savedInstanceState);
55   -
56   -
57   - CameraManager.init(getActivity().getApplication());
58   -
59   - hasSurface = false;
60   - inactivityTimer = new InactivityTimer(this.getActivity());
61   - }
62   -
63   - @Nullable
64   - @Override
65   - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
66   -
67   - Bundle bundle = getArguments();
68   - View view = null;
69   - if (bundle != null) {
70   - int layoutId = bundle.getInt(CodeUtils.LAYOUT_ID);
71   - if (layoutId != -1) {
72   - view = inflater.inflate(layoutId, null);
73   - }
74   - }
75   -
76   - if (view == null) {
77   - view = inflater.inflate(R.layout.fragment_capture, null);
78   - }
79   -
80   - viewfinderView = (ViewfinderView) view.findViewById(R.id.viewfinder_view);
81   - surfaceView = (SurfaceView) view.findViewById(R.id.preview_view);
82   - surfaceHolder = surfaceView.getHolder();
83   -
84   - return view;
85   - }
86   -
87   - @Override
88   - public void onResume() {
89   - super.onResume();
90   - if (hasSurface) {
91   - initCamera(surfaceHolder);
92   - } else {
93   - surfaceHolder.addCallback(this);
94   - surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
95   - }
96   - decodeFormats = null;
97   - characterSet = null;
98   -
99   - playBeep = true;
100   - AudioManager audioService = (AudioManager) getActivity().getSystemService(getActivity().AUDIO_SERVICE);
101   - if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
102   - playBeep = false;
103   - }
104   - initBeepSound();
105   - vibrate = true;
106   - }
107   -
108   - @Override
109   - public void onPause() {
110   - super.onPause();
111   - if (handler != null) {
112   - handler.quitSynchronously();
113   - handler = null;
114   - }
115   - CameraManager.get().closeDriver();
116   - }
117   -
118   - @Override
119   - public void onDestroy() {
120   - super.onDestroy();
121   - inactivityTimer.shutdown();
122   - }
123   -
124   -
125   - /**
126   - * Handler scan result
127   - *
128   - * @param result
129   - * @param barcode
130   - */
131   - public void handleDecode(Result result, Bitmap barcode) {
132   - inactivityTimer.onActivity();
133   - playBeepSoundAndVibrate();
134   -
135   - if (result == null || TextUtils.isEmpty(result.getText())) {
136   - if (analyzeCallback != null) {
137   - analyzeCallback.onAnalyzeFailed();
138   - }
139   - } else {
140   - if (analyzeCallback != null) {
141   - analyzeCallback.onAnalyzeSuccess(barcode, result.getText());
142   - }
143   - }
144   - }
145   -
146   - private void initCamera(SurfaceHolder surfaceHolder) {
147   - try {
148   - CameraManager.get().openDriver(surfaceHolder);
149   - camera = CameraManager.get().getCamera();
150   - } catch (Exception e) {
151   - if (callBack != null) {
152   - callBack.callBack(e);
153   - }
154   - return;
155   - }
156   - if (callBack != null) {
157   - callBack.callBack(null);
158   - }
159   - if (handler == null) {
160   - handler = new CaptureActivityHandler(this, decodeFormats, characterSet, viewfinderView);
161   - }
162   - }
163   -
164   - @Override
165   - public void surfaceChanged(SurfaceHolder holder, int format, int width,
166   - int height) {
167   -
168   - }
169   -
170   - @Override
171   - public void surfaceCreated(SurfaceHolder holder) {
172   - if (!hasSurface) {
173   - hasSurface = true;
174   - initCamera(holder);
175   - }
176   -
177   - }
178   -
179   - @Override
180   - public void surfaceDestroyed(SurfaceHolder holder) {
181   - hasSurface = false;
182   - if (camera != null) {
183   - if (camera != null && CameraManager.get().isPreviewing()) {
184   - if (!CameraManager.get().isUseOneShotPreviewCallback()) {
185   - camera.setPreviewCallback(null);
186   - }
187   - camera.stopPreview();
188   - CameraManager.get().getPreviewCallback().setHandler(null, 0);
189   - CameraManager.get().getAutoFocusCallback().setHandler(null, 0);
190   - CameraManager.get().setPreviewing(false);
191   - }
192   - }
193   - }
194   -
195   - public Handler getHandler() {
196   - return handler;
197   - }
198   -
199   - public void drawViewfinder() {
200   - viewfinderView.drawViewfinder();
201   -
202   - }
203   -
204   - private void initBeepSound() {
205   - if (playBeep && mediaPlayer == null) {
206   - // The volume on STREAM_SYSTEM is not adjustable, and users found it
207   - // too loud,
208   - // so we now play on the music stream.
209   - getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
210   - mediaPlayer = new MediaPlayer();
211   - mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
212   - mediaPlayer.setOnCompletionListener(beepListener);
213   -
214   - AssetFileDescriptor file = getResources().openRawResourceFd(
215   - R.raw.beep);
216   - try {
217   - mediaPlayer.setDataSource(file.getFileDescriptor(),
218   - file.getStartOffset(), file.getLength());
219   - file.close();
220   - mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
221   - mediaPlayer.prepare();
222   - } catch (IOException e) {
223   - mediaPlayer = null;
224   - }
225   - }
226   - }
227   -
228   - private static final long VIBRATE_DURATION = 200L;
229   -
230   - private void playBeepSoundAndVibrate() {
231   - if (playBeep && mediaPlayer != null) {
232   - mediaPlayer.start();
233   - }
234   - if (vibrate) {
235   - Vibrator vibrator = (Vibrator) getActivity().getSystemService(getActivity().VIBRATOR_SERVICE);
236   - vibrator.vibrate(VIBRATE_DURATION);
237   - }
238   - }
239   -
240   - /**
241   - * When the beep has finished playing, rewind to queue up another one.
242   - */
243   - private final MediaPlayer.OnCompletionListener beepListener = new MediaPlayer.OnCompletionListener() {
244   - public void onCompletion(MediaPlayer mediaPlayer) {
245   - mediaPlayer.seekTo(0);
246   - }
247   - };
248   -
249   - public CodeUtils.AnalyzeCallback getAnalyzeCallback() {
250   - return analyzeCallback;
251   - }
252   -
253   - public void setAnalyzeCallback(CodeUtils.AnalyzeCallback analyzeCallback) {
254   - this.analyzeCallback = analyzeCallback;
255   - }
256   -
257   - @Nullable
258   - CameraInitCallBack callBack;
259   -
260   - /**
261   - * Set callback for Camera check whether Camera init success or not.
262   - */
263   - public void setCameraInitCallBack(CameraInitCallBack callBack) {
264   - this.callBack = callBack;
265   - }
266   -
267   - interface CameraInitCallBack {
268   - /**
269   - * Callback for Camera init result.
270   - * @param e If is's null,means success.otherwise Camera init failed with the Exception.
271   - */
272   - void callBack(Exception e);
273   - }
274   -
275   -
276   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/activity/CodeUtils.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.activity;
2   -
3   -import android.graphics.Bitmap;
4   -import android.graphics.BitmapFactory;
5   -import android.graphics.Matrix;
6   -import android.hardware.Camera;
7   -import android.os.Bundle;
8   -import android.text.TextUtils;
9   -
10   -import com.google.zxing.BarcodeFormat;
11   -import com.google.zxing.BinaryBitmap;
12   -import com.google.zxing.DecodeHintType;
13   -import com.google.zxing.EncodeHintType;
14   -import com.google.zxing.MultiFormatReader;
15   -import com.google.zxing.Result;
16   -import com.google.zxing.WriterException;
17   -import com.google.zxing.common.BitMatrix;
18   -import com.google.zxing.common.HybridBinarizer;
19   -import com.google.zxing.qrcode.QRCodeWriter;
20   -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
21   -import com.uuzuche.lib_zxing.camera.BitmapLuminanceSource;
22   -import com.uuzuche.lib_zxing.camera.CameraManager;
23   -import com.uuzuche.lib_zxing.decoding.DecodeFormatManager;
24   -
25   -import java.util.Hashtable;
26   -import java.util.Vector;
27   -
28   -/**
29   - * Created by aaron on 16/7/27.
30   - * 二维码扫描工具类
31   - */
32   -public class CodeUtils {
33   -
34   - public static final String RESULT_TYPE = "result_type";
35   - public static final String RESULT_STRING = "result_string";
36   - public static final int RESULT_SUCCESS = 1;
37   - public static final int RESULT_FAILED = 2;
38   -
39   - public static final String LAYOUT_ID = "layout_id";
40   -
41   -
42   -
43   - /**
44   - * 解析二维码图片工具类
45   - * @param analyzeCallback
46   - */
47   - public static void analyzeBitmap(String path, AnalyzeCallback analyzeCallback) {
48   -
49   - /**
50   - * 首先判断图片的大小,若图片过大,则执行图片的裁剪操作,防止OOM
51   - */
52   - BitmapFactory.Options options = new BitmapFactory.Options();
53   - options.inJustDecodeBounds = true; // 先获取原大小
54   - Bitmap mBitmap = BitmapFactory.decodeFile(path, options);
55   - options.inJustDecodeBounds = false; // 获取新的大小
56   -
57   - int sampleSize = (int) (options.outHeight / (float) 400);
58   -
59   - if (sampleSize <= 0)
60   - sampleSize = 1;
61   - options.inSampleSize = sampleSize;
62   - mBitmap = BitmapFactory.decodeFile(path, options);
63   -
64   - MultiFormatReader multiFormatReader = new MultiFormatReader();
65   -
66   - // 解码的参数
67   - Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(2);
68   - // 可以解析的编码类型
69   - Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();
70   - if (decodeFormats == null || decodeFormats.isEmpty()) {
71   - decodeFormats = new Vector<BarcodeFormat>();
72   -
73   - // 这里设置可扫描的类型,我这里选择了都支持
74   - decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
75   - decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
76   - decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
77   - }
78   - hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
79   - // 设置继续的字符编码格式为UTF8
80   - // hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
81   - // 设置解析配置参数
82   - multiFormatReader.setHints(hints);
83   -
84   - // 开始对图像资源解码
85   - Result rawResult = null;
86   - try {
87   - rawResult = multiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(mBitmap))));
88   - } catch (Exception e) {
89   - e.printStackTrace();
90   - }
91   -
92   - if (rawResult != null) {
93   - if (analyzeCallback != null) {
94   - analyzeCallback.onAnalyzeSuccess(mBitmap, rawResult.getText());
95   - }
96   - } else {
97   - if (analyzeCallback != null) {
98   - analyzeCallback.onAnalyzeFailed();
99   - }
100   - }
101   - }
102   -
103   - /**
104   - * 生成二维码图片
105   - * @param text
106   - * @param w
107   - * @param h
108   - * @param logo
109   - * @return
110   - */
111   - public static Bitmap createImage(String text, int w, int h, Bitmap logo) {
112   - if (TextUtils.isEmpty(text)) {
113   - return null;
114   - }
115   - try {
116   - Bitmap scaleLogo = getScaleLogo(logo,w,h);
117   -
118   - int offsetX = w / 2;
119   - int offsetY = h / 2;
120   -
121   - int scaleWidth = 0;
122   - int scaleHeight = 0;
123   - if (scaleLogo != null) {
124   - scaleWidth = scaleLogo.getWidth();
125   - scaleHeight = scaleLogo.getHeight();
126   - offsetX = (w - scaleWidth) / 2;
127   - offsetY = (h - scaleHeight) / 2;
128   - }
129   - Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
130   - hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
131   - //容错级别
132   - hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
133   - //设置空白边距的宽度
134   - hints.put(EncodeHintType.MARGIN, 0);
135   - BitMatrix bitMatrix = new QRCodeWriter().encode(text, BarcodeFormat.QR_CODE, w, h, hints);
136   - int[] pixels = new int[w * h];
137   - for (int y = 0; y < h; y++) {
138   - for (int x = 0; x < w; x++) {
139   - if(x >= offsetX && x < offsetX + scaleWidth && y>= offsetY && y < offsetY + scaleHeight){
140   - int pixel = scaleLogo.getPixel(x-offsetX,y-offsetY);
141   - if(pixel == 0){
142   - if(bitMatrix.get(x, y)){
143   - pixel = 0xff000000;
144   - }else{
145   - pixel = 0xffffffff;
146   - }
147   - }
148   - pixels[y * w + x] = pixel;
149   - }else{
150   - if (bitMatrix.get(x, y)) {
151   - pixels[y * w + x] = 0xff000000;
152   - } else {
153   - pixels[y * w + x] = 0xffffffff;
154   - }
155   - }
156   - }
157   - }
158   - Bitmap bitmap = Bitmap.createBitmap(w, h,
159   - Bitmap.Config.ARGB_8888);
160   - bitmap.setPixels(pixels, 0, w, 0, 0, w, h);
161   - return bitmap;
162   - } catch (WriterException e) {
163   - e.printStackTrace();
164   - }
165   - return null;
166   - }
167   -
168   - private static Bitmap getScaleLogo(Bitmap logo, int w, int h){
169   - if(logo == null)return null;
170   - Matrix matrix = new Matrix();
171   - float scaleFactor = Math.min(w * 1.0f / 5 / logo.getWidth(), h * 1.0f / 5 /logo.getHeight());
172   - matrix.postScale(scaleFactor,scaleFactor);
173   - Bitmap result = Bitmap.createBitmap(logo, 0, 0, logo.getWidth(), logo.getHeight(), matrix, true);
174   - return result;
175   - }
176   -
177   - /**
178   - * 解析二维码结果
179   - */
180   - public interface AnalyzeCallback{
181   -
182   - public void onAnalyzeSuccess(Bitmap mBitmap, String result);
183   -
184   - public void onAnalyzeFailed();
185   - }
186   -
187   -
188   - /**
189   - * 为CaptureFragment设置layout参数
190   - * @param captureFragment
191   - * @param layoutId
192   - */
193   - public static void setFragmentArgs(CaptureFragment captureFragment, int layoutId) {
194   - if (captureFragment == null || layoutId == -1) {
195   - return;
196   - }
197   -
198   - Bundle bundle = new Bundle();
199   - bundle.putInt(LAYOUT_ID, layoutId);
200   - captureFragment.setArguments(bundle);
201   - }
202   -
203   - public static void isLightEnable(boolean isEnable) {
204   - if (isEnable) {
205   - Camera camera = CameraManager.get().getCamera();
206   - if (camera != null) {
207   - Camera.Parameters parameter = camera.getParameters();
208   - parameter.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
209   - camera.setParameters(parameter);
210   - }
211   - } else {
212   - Camera camera = CameraManager.get().getCamera();
213   - if (camera != null) {
214   - Camera.Parameters parameter = camera.getParameters();
215   - parameter.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
216   - camera.setParameters(parameter);
217   - }
218   - }
219   - }
220   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/activity/ZXingLibrary.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.activity;
2   -
3   -import android.content.Context;
4   -import android.util.DisplayMetrics;
5   -
6   -import com.uuzuche.lib_zxing.DisplayUtil;
7   -
8   -/**
9   - * Created by aaron on 16/9/7.
10   - */
11   -
12   -public class ZXingLibrary {
13   -
14   - public static void initDisplayOpinion(Context context) {
15   - if (context == null) {
16   - return;
17   - }
18   - DisplayMetrics dm = context.getResources().getDisplayMetrics();
19   - DisplayUtil.density = dm.density;
20   - DisplayUtil.densityDPI = dm.densityDpi;
21   - DisplayUtil.screenWidthPx = dm.widthPixels;
22   - DisplayUtil.screenhightPx = dm.heightPixels;
23   - DisplayUtil.screenWidthDip = DisplayUtil.px2dip(context, dm.widthPixels);
24   - DisplayUtil.screenHightDip = DisplayUtil.px2dip(context, dm.heightPixels);
25   - }
26   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/AutoFocusCallback.java deleted 100644 → 0
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.uuzuche.lib_zxing.camera;
18   -
19   -import android.hardware.Camera;
20   -import android.os.Handler;
21   -import android.os.Message;
22   -import android.util.Log;
23   -
24   -public final class AutoFocusCallback implements Camera.AutoFocusCallback {
25   -
26   - private static final String TAG = AutoFocusCallback.class.getSimpleName();
27   -
28   - private static final long AUTOFOCUS_INTERVAL_MS = 1500L;
29   -
30   - private Handler autoFocusHandler;
31   - private int autoFocusMessage;
32   -
33   - public void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
34   - this.autoFocusHandler = autoFocusHandler;
35   - this.autoFocusMessage = autoFocusMessage;
36   - }
37   -
38   - public void onAutoFocus(boolean success, Camera camera) {
39   - if (autoFocusHandler != null) {
40   - Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
41   - autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
42   - autoFocusHandler = null;
43   - } else {
44   - Log.d(TAG, "Got auto-focus callback, but no handler for it");
45   - }
46   - }
47   -
48   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/BitmapLuminanceSource.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.camera;
2   -
3   -import android.graphics.Bitmap;
4   -
5   -import com.google.zxing.LuminanceSource;
6   -
7   -/**
8   - * Created by aaron on 16/7/27.
9   - * 自定义解析Bitmap LuminanceSource
10   - */
11   -public class BitmapLuminanceSource extends LuminanceSource {
12   -
13   - private byte bitmapPixels[];
14   -
15   - public BitmapLuminanceSource(Bitmap bitmap) {
16   - super(bitmap.getWidth(), bitmap.getHeight());
17   -
18   - // 首先,要取得该图片的像素数组内容
19   - int[] data = new int[bitmap.getWidth() * bitmap.getHeight()];
20   - this.bitmapPixels = new byte[bitmap.getWidth() * bitmap.getHeight()];
21   - bitmap.getPixels(data, 0, getWidth(), 0, 0, getWidth(), getHeight());
22   -
23   - // 将int数组转换为byte数组,也就是取像素值中蓝色值部分作为辨析内容
24   - for (int i = 0; i < data.length; i++) {
25   - this.bitmapPixels[i] = (byte) data[i];
26   - }
27   - }
28   -
29   - @Override
30   - public byte[] getMatrix() {
31   - // 返回我们生成好的像素数据
32   - return bitmapPixels;
33   - }
34   -
35   - @Override
36   - public byte[] getRow(int y, byte[] row) {
37   - // 这里要得到指定行的像素数据
38   - System.arraycopy(bitmapPixels, y * getWidth(), row, 0, getWidth());
39   - return row;
40   - }
41   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/CameraConfigurationManager.java deleted 100644 → 0
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.uuzuche.lib_zxing.camera;
18   -
19   -import android.content.Context;
20   -import android.graphics.Point;
21   -import android.hardware.Camera;
22   -import android.os.Build;
23   -import android.util.Log;
24   -import android.view.Display;
25   -import android.view.WindowManager;
26   -
27   -import java.util.regex.Pattern;
28   -
29   -final class CameraConfigurationManager {
30   -
31   - private static final String TAG = CameraConfigurationManager.class.getSimpleName();
32   -
33   - private static final int TEN_DESIRED_ZOOM = 27;
34   - private static final int DESIRED_SHARPNESS = 30;
35   -
36   - private static final Pattern COMMA_PATTERN = Pattern.compile(",");
37   -
38   - private final Context context;
39   - private Point screenResolution;
40   - private Point cameraResolution;
41   - private int previewFormat;
42   - private String previewFormatString;
43   -
44   - CameraConfigurationManager(Context context) {
45   - this.context = context;
46   - }
47   -
48   - /**
49   - * Reads, one time, values from the camera that are needed by the app.
50   - */
51   - void initFromCameraParameters(Camera camera) {
52   - Camera.Parameters parameters = camera.getParameters();
53   - previewFormat = parameters.getPreviewFormat();
54   - previewFormatString = parameters.get("preview-format");
55   - Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
56   - WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
57   - Display display = manager.getDefaultDisplay();
58   - screenResolution = new Point(display.getWidth(), display.getHeight());
59   - Log.d(TAG, "Screen resolution: " + screenResolution);
60   -
61   - Point screenResolutionForCamera = new Point();
62   - screenResolutionForCamera.x = screenResolution.x;
63   - screenResolutionForCamera.y = screenResolution.y;
64   - // preview size is always something like 480*320, other 320*480
65   - if (screenResolution.x < screenResolution.y) {
66   - screenResolutionForCamera.x = screenResolution.y;
67   - screenResolutionForCamera.y = screenResolution.x;
68   - }
69   - Log.i("#########", "screenX:" + screenResolutionForCamera.x + " screenY:" + screenResolutionForCamera.y);
70   - cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
71   -
72   - // cameraResolution = getCameraResolution(parameters, screenResolution);
73   - Log.d(TAG, "Camera resolution: " + screenResolution);
74   - }
75   -
76   - /**
77   - * Sets the camera up to take preview images which are used for both preview and decoding.
78   - * We detect the preview format here so that buildLuminanceSource() can build an appropriate
79   - * LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
80   - * and the planar Y can be used for barcode scanning without a copy in some cases.
81   - */
82   - void setDesiredCameraParameters(Camera camera) {
83   - Camera.Parameters parameters = camera.getParameters();
84   - Log.d(TAG, "Setting preview size: " + cameraResolution);
85   - parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
86   - setFlash(parameters);
87   - setZoom(parameters);
88   - //setSharpness(parameters);
89   - //modify here
90   - camera.setDisplayOrientation(90);
91   - camera.setParameters(parameters);
92   - }
93   -
94   - Point getCameraResolution() {
95   - return cameraResolution;
96   - }
97   -
98   - Point getScreenResolution() {
99   - return screenResolution;
100   - }
101   -
102   - int getPreviewFormat() {
103   - return previewFormat;
104   - }
105   -
106   - String getPreviewFormatString() {
107   - return previewFormatString;
108   - }
109   -
110   - private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) {
111   -
112   - String previewSizeValueString = parameters.get("preview-size-values");
113   - // saw this on Xperia
114   - if (previewSizeValueString == null) {
115   - previewSizeValueString = parameters.get("preview-size-value");
116   - }
117   -
118   - Point cameraResolution = null;
119   -
120   - if (previewSizeValueString != null) {
121   - Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString);
122   - cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
123   - }
124   -
125   - if (cameraResolution == null) {
126   - // Ensure that the camera resolution is a multiple of 8, as the screen may not be.
127   - cameraResolution = new Point(
128   - (screenResolution.x >> 3) << 3,
129   - (screenResolution.y >> 3) << 3);
130   - }
131   -
132   - return cameraResolution;
133   - }
134   -
135   - private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
136   - int bestX = 0;
137   - int bestY = 0;
138   - int diff = Integer.MAX_VALUE;
139   - for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
140   -
141   - previewSize = previewSize.trim();
142   - int dimPosition = previewSize.indexOf('x');
143   - if (dimPosition < 0) {
144   - Log.w(TAG, "Bad preview-size: " + previewSize);
145   - continue;
146   - }
147   -
148   - int newX;
149   - int newY;
150   - try {
151   - newX = Integer.parseInt(previewSize.substring(0, dimPosition));
152   - newY = Integer.parseInt(previewSize.substring(dimPosition + 1));
153   - } catch (NumberFormatException nfe) {
154   - Log.w(TAG, "Bad preview-size: " + previewSize);
155   - continue;
156   - }
157   -
158   - int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y);
159   - if (newDiff == 0) {
160   - bestX = newX;
161   - bestY = newY;
162   - break;
163   - } else if (newDiff < diff) {
164   - bestX = newX;
165   - bestY = newY;
166   - diff = newDiff;
167   - }
168   -
169   - }
170   -
171   - if (bestX > 0 && bestY > 0) {
172   - return new Point(bestX, bestY);
173   - }
174   - return null;
175   - }
176   -
177   - private static int findBestMotZoomValue(CharSequence stringValues, int tenDesiredZoom) {
178   - int tenBestValue = 0;
179   - for (String stringValue : COMMA_PATTERN.split(stringValues)) {
180   - stringValue = stringValue.trim();
181   - double value;
182   - try {
183   - value = Double.parseDouble(stringValue);
184   - } catch (NumberFormatException nfe) {
185   - return tenDesiredZoom;
186   - }
187   - int tenValue = (int) (10.0 * value);
188   - if (Math.abs(tenDesiredZoom - value) < Math.abs(tenDesiredZoom - tenBestValue)) {
189   - tenBestValue = tenValue;
190   - }
191   - }
192   - return tenBestValue;
193   - }
194   -
195   - private void setFlash(Camera.Parameters parameters) {
196   - // FIXME: This is a hack to turn the flash off on the Samsung Galaxy.
197   - // And this is a hack-hack to work around a different value on the Behold II
198   - // Restrict Behold II check to Cupcake, per Samsung's advice
199   - //if (Build.MODEL.contains("Behold II") &&
200   - // CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
201   - if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
202   - parameters.set("flash-value", 1);
203   - } else {
204   - parameters.set("flash-value", 2);
205   - }
206   - // This is the standard setting to turn the flash off that all devices should honor.
207   - parameters.set("flash-mode", "off");
208   - }
209   -
210   - private void setZoom(Camera.Parameters parameters) {
211   -
212   - String zoomSupportedString = parameters.get("zoom-supported");
213   - if (zoomSupportedString != null && !Boolean.parseBoolean(zoomSupportedString)) {
214   - return;
215   - }
216   -
217   - int tenDesiredZoom = TEN_DESIRED_ZOOM;
218   -
219   - String maxZoomString = parameters.get("max-zoom");
220   - if (maxZoomString != null) {
221   - try {
222   - int tenMaxZoom = (int) (10.0 * Double.parseDouble(maxZoomString));
223   - if (tenDesiredZoom > tenMaxZoom) {
224   - tenDesiredZoom = tenMaxZoom;
225   - }
226   - } catch (NumberFormatException nfe) {
227   - Log.w(TAG, "Bad max-zoom: " + maxZoomString);
228   - }
229   - }
230   -
231   - String takingPictureZoomMaxString = parameters.get("taking-picture-zoom-max");
232   - if (takingPictureZoomMaxString != null) {
233   - try {
234   - int tenMaxZoom = Integer.parseInt(takingPictureZoomMaxString);
235   - if (tenDesiredZoom > tenMaxZoom) {
236   - tenDesiredZoom = tenMaxZoom;
237   - }
238   - } catch (NumberFormatException nfe) {
239   - Log.w(TAG, "Bad taking-picture-zoom-max: " + takingPictureZoomMaxString);
240   - }
241   - }
242   -
243   - String motZoomValuesString = parameters.get("mot-zoom-values");
244   - if (motZoomValuesString != null) {
245   - tenDesiredZoom = findBestMotZoomValue(motZoomValuesString, tenDesiredZoom);
246   - }
247   -
248   - String motZoomStepString = parameters.get("mot-zoom-step");
249   - if (motZoomStepString != null) {
250   - try {
251   - double motZoomStep = Double.parseDouble(motZoomStepString.trim());
252   - int tenZoomStep = (int) (10.0 * motZoomStep);
253   - if (tenZoomStep > 1) {
254   - tenDesiredZoom -= tenDesiredZoom % tenZoomStep;
255   - }
256   - } catch (NumberFormatException nfe) {
257   - // continue
258   - }
259   - }
260   -
261   - // Set zoom. This helps encourage the user to pull back.
262   - // Some devices like the Behold have a zoom parameter
263   - if (maxZoomString != null || motZoomValuesString != null) {
264   - parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0));
265   - }
266   -
267   - // Most devices, like the Hero, appear to expose this zoom parameter.
268   - // It takes on values like "27" which appears to mean 2.7x zoom
269   - if (takingPictureZoomMaxString != null) {
270   - parameters.set("taking-picture-zoom", tenDesiredZoom);
271   - }
272   - }
273   -
274   - public static int getDesiredSharpness() {
275   - return DESIRED_SHARPNESS;
276   - }
277   -
278   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/CameraManager.java deleted 100644 → 0
1   -/*
2   - * Copyright (C) 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.uuzuche.lib_zxing.camera;
18   -
19   -import android.content.Context;
20   -import android.graphics.PixelFormat;
21   -import android.graphics.Point;
22   -import android.graphics.Rect;
23   -import android.hardware.Camera;
24   -import android.os.Build;
25   -import android.os.Handler;
26   -import android.view.SurfaceHolder;
27   -
28   -import java.io.IOException;
29   -
30   -/**
31   - * This object wraps the Camera service object and expects to be the only one talking to it. The
32   - * implementation encapsulates the steps needed to take preview-sized images, which are used for
33   - * both preview and decoding.
34   - */
35   -public final class CameraManager {
36   -
37   - private static final String TAG = CameraManager.class.getSimpleName();
38   -
39   - public static int FRAME_WIDTH = -1;
40   - public static int FRAME_HEIGHT = -1;
41   - public static int FRAME_MARGINTOP = -1;
42   -
43   - private static CameraManager cameraManager;
44   -
45   - static final int SDK_INT; // Later we can use Build.VERSION.SDK_INT
46   -
47   - static {
48   - int sdkInt;
49   - try {
50   - sdkInt = Integer.parseInt(Build.VERSION.SDK);
51   - } catch (NumberFormatException nfe) {
52   - // Just to be safe
53   - sdkInt = 10000;
54   - }
55   - SDK_INT = sdkInt;
56   - }
57   -
58   - private final Context context;
59   - private final CameraConfigurationManager configManager;
60   - private Camera camera;
61   - private Rect framingRect;
62   - private Rect framingRectInPreview;
63   - private boolean initialized;
64   - private boolean previewing;
65   - private final boolean useOneShotPreviewCallback;
66   - /**
67   - * Preview frames are delivered here, which we pass on to the registered handler. Make sure to
68   - * clear the handler so it will only receive one message.
69   - */
70   - private final PreviewCallback previewCallback;
71   - /**
72   - * Autofocus callbacks arrive here, and are dispatched to the Handler which requested them.
73   - */
74   - private final AutoFocusCallback autoFocusCallback;
75   -
76   - /**
77   - * Initializes this static object with the Context of the calling Activity.
78   - *
79   - * @param context The Activity which wants to use the camera.
80   - */
81   - public static void init(Context context) {
82   - if (cameraManager == null) {
83   - cameraManager = new CameraManager(context);
84   - }
85   - }
86   -
87   - /**
88   - * Gets the CameraManager singleton instance.
89   - *
90   - * @return A reference to the CameraManager singleton.
91   - */
92   - public static CameraManager get() {
93   - return cameraManager;
94   - }
95   -
96   - private CameraManager(Context context) {
97   -
98   - this.context = context;
99   - this.configManager = new CameraConfigurationManager(context);
100   -
101   - // Camera.setOneShotPreviewCallback() has a race condition in Cupcake, so we use the older
102   - // Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
103   - // the more efficient one shot callback, as the older one can swamp the system and cause it
104   - // to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
105   - //useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE;
106   - useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // 3 = Cupcake
107   -
108   - previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback);
109   - autoFocusCallback = new AutoFocusCallback();
110   - }
111   -
112   - /**
113   - * Opens the camera driver and initializes the hardware parameters.
114   - *
115   - * @param holder The surface object which the camera will draw preview frames into.
116   - * @throws IOException Indicates the camera driver failed to open.
117   - */
118   - public void openDriver(SurfaceHolder holder) throws IOException {
119   - if (camera == null) {
120   - camera = Camera.open();
121   - if (camera == null) {
122   - throw new IOException();
123   - }
124   - camera.setPreviewDisplay(holder);
125   -
126   - if (!initialized) {
127   - initialized = true;
128   - configManager.initFromCameraParameters(camera);
129   - }
130   - configManager.setDesiredCameraParameters(camera);
131   -
132   - //FIXME
133   - // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
134   - //�Ƿ�ʹ��ǰ��
135   -// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) {
136   -// FlashlightManager.enableFlashlight();
137   -// }
138   - FlashlightManager.enableFlashlight();
139   - }
140   - }
141   -
142   - /**
143   - * Closes the camera driver if still in use.
144   - */
145   - public void closeDriver() {
146   - if (camera != null) {
147   - FlashlightManager.disableFlashlight();
148   - camera.release();
149   - camera = null;
150   - }
151   - }
152   -
153   - /**
154   - * Asks the camera hardware to begin drawing preview frames to the screen.
155   - */
156   - public void startPreview() {
157   - if (camera != null && !previewing) {
158   - camera.startPreview();
159   - previewing = true;
160   - }
161   - }
162   -
163   - /**
164   - * Tells the camera to stop drawing preview frames.
165   - */
166   - public void stopPreview() {
167   - if (camera != null && previewing) {
168   - if (!useOneShotPreviewCallback) {
169   - camera.setPreviewCallback(null);
170   - }
171   - camera.stopPreview();
172   - previewCallback.setHandler(null, 0);
173   - autoFocusCallback.setHandler(null, 0);
174   - previewing = false;
175   - }
176   - }
177   -
178   - /**
179   - * A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
180   - * in the message.obj field, with width and height encoded as message.arg1 and message.arg2,
181   - * respectively.
182   - *
183   - * @param handler The handler to send the message to.
184   - * @param message The what field of the message to be sent.
185   - */
186   - public void requestPreviewFrame(Handler handler, int message) {
187   - if (camera != null && previewing) {
188   - previewCallback.setHandler(handler, message);
189   - if (useOneShotPreviewCallback) {
190   - camera.setOneShotPreviewCallback(previewCallback);
191   - } else {
192   - camera.setPreviewCallback(previewCallback);
193   - }
194   - }
195   - }
196   -
197   - /**
198   - * Asks the camera hardware to perform an autofocus.
199   - *
200   - * @param handler The Handler to notify when the autofocus completes.
201   - * @param message The message to deliver.
202   - */
203   - public void requestAutoFocus(Handler handler, int message) {
204   - if (camera != null && previewing) {
205   - autoFocusCallback.setHandler(handler, message);
206   - //Log.d(TAG, "Requesting auto-focus callback");
207   - camera.autoFocus(autoFocusCallback);
208   - }
209   - }
210   -
211   - /**
212   - * Calculates the framing rect which the UI should draw to show the user where to place the
213   - * barcode. This target helps with alignment as well as forces the user to hold the device
214   - * far enough away to ensure the image will be in focus.
215   - *
216   - * @return The rectangle to draw on screen in window coordinates.
217   - */
218   - public Rect getFramingRect() {
219   - try {
220   - Point screenResolution = configManager.getScreenResolution();
221   - // if (framingRect == null) {
222   - if (camera == null) {
223   - return null;
224   - }
225   -
226   - int leftOffset = (screenResolution.x - FRAME_WIDTH) / 2;
227   -
228   - int topOffset;
229   - if (FRAME_MARGINTOP != -1) {
230   - topOffset = FRAME_MARGINTOP;
231   - } else {
232   - topOffset = (screenResolution.y - FRAME_HEIGHT) / 2;
233   - }
234   - framingRect = new Rect(leftOffset, topOffset, leftOffset + FRAME_WIDTH, topOffset + FRAME_HEIGHT);
235   - // }
236   - return framingRect;
237   - } catch (Exception e) {
238   - e.printStackTrace();
239   - return null;
240   - }
241   - }
242   -
243   - /**
244   - * Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
245   - * not UI / screen.
246   - */
247   - public Rect getFramingRectInPreview() {
248   - if (framingRectInPreview == null) {
249   - Rect rect = new Rect(getFramingRect());
250   - Point cameraResolution = configManager.getCameraResolution();
251   - Point screenResolution = configManager.getScreenResolution();
252   - //modify here
253   -// rect.left = rect.left * cameraResolution.x / screenResolution.x;
254   -// rect.right = rect.right * cameraResolution.x / screenResolution.x;
255   -// rect.top = rect.top * cameraResolution.y / screenResolution.y;
256   -// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
257   - rect.left = rect.left * cameraResolution.y / screenResolution.x;
258   - rect.right = rect.right * cameraResolution.y / screenResolution.x;
259   - rect.top = rect.top * cameraResolution.x / screenResolution.y;
260   - rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
261   - framingRectInPreview = rect;
262   - }
263   - return framingRectInPreview;
264   - }
265   -
266   - /**
267   - * Converts the result points from still resolution coordinates to screen coordinates.
268   - *
269   - * @param points The points returned by the Reader subclass through Result.getResultPoints().
270   - * @return An array of Points scaled to the size of the framing rect and offset appropriately
271   - * so they can be drawn in screen coordinates.
272   - */
273   - /*
274   - public Point[] convertResultPoints(ResultPoint[] points) {
275   - Rect frame = getFramingRectInPreview();
276   - int count = points.length;
277   - Point[] output = new Point[count];
278   - for (int x = 0; x < count; x++) {
279   - output[x] = new Point();
280   - output[x].x = frame.left + (int) (points[x].getX() + 0.5f);
281   - output[x].y = frame.top + (int) (points[x].getY() + 0.5f);
282   - }
283   - return output;
284   - }
285   - */
286   -
287   - /**
288   - * A factory method to build the appropriate LuminanceSource object based on the format
289   - * of the preview buffers, as described by Camera.Parameters.
290   - *
291   - * @param data A preview frame.
292   - * @param width The width of the image.
293   - * @param height The height of the image.
294   - * @return A PlanarYUVLuminanceSource instance.
295   - */
296   - public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
297   - Rect rect = getFramingRectInPreview();
298   - int previewFormat = configManager.getPreviewFormat();
299   - String previewFormatString = configManager.getPreviewFormatString();
300   - switch (previewFormat) {
301   - // This is the standard Android format which all devices are REQUIRED to support.
302   - // In theory, it's the only one we should ever care about.
303   - case PixelFormat.YCbCr_420_SP:
304   - // This format has never been seen in the wild, but is compatible as we only care
305   - // about the Y channel, so allow it.
306   - case PixelFormat.YCbCr_422_SP:
307   - return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
308   - rect.width(), rect.height());
309   - default:
310   - // The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
311   - // Fortunately, it too has all the Y data up front, so we can read it.
312   - if ("yuv420p".equals(previewFormatString)) {
313   - return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
314   - rect.width(), rect.height());
315   - }
316   - }
317   - throw new IllegalArgumentException("Unsupported picture format: " +
318   - previewFormat + '/' + previewFormatString);
319   - }
320   -
321   - public Context getContext() {
322   - return context;
323   - }
324   -
325   - public Camera getCamera() {
326   - return camera;
327   - }
328   -
329   - public boolean isPreviewing() {
330   - return previewing;
331   - }
332   -
333   - public boolean isUseOneShotPreviewCallback() {
334   - return useOneShotPreviewCallback;
335   - }
336   -
337   - public PreviewCallback getPreviewCallback() {
338   - return previewCallback;
339   - }
340   -
341   - public AutoFocusCallback getAutoFocusCallback() {
342   - return autoFocusCallback;
343   - }
344   -
345   - public void setPreviewing(boolean previewing) {
346   - this.previewing = previewing;
347   - }
348   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/FlashlightManager.java deleted 100644 → 0
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.uuzuche.lib_zxing.camera;
18   -
19   -import android.os.IBinder;
20   -import android.util.Log;
21   -
22   -import java.lang.reflect.InvocationTargetException;
23   -import java.lang.reflect.Method;
24   -
25   -/**
26   - * This class is used to activate the weak light on some camera phones (not flash)
27   - * in order to illuminate surfaces for scanning. There is no official way to do this,
28   - * but, classes which allow access to this function still exist on some devices.
29   - * This therefore proceeds through a great deal of reflection.
30   - * <p>
31   - * See <a href="http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/">
32   - * http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/</a> and
33   - * <a href="http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java">
34   - * http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java</a>.
35   - * Thanks to Ryan Alford for pointing out the availability of this class.
36   - */
37   -final class FlashlightManager {
38   -
39   - private static final String TAG = FlashlightManager.class.getSimpleName();
40   -
41   - private static final Object iHardwareService;
42   - private static final Method setFlashEnabledMethod;
43   -
44   - static {
45   - iHardwareService = getHardwareService();
46   - setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
47   - if (iHardwareService == null) {
48   - Log.v(TAG, "This device does supports control of a flashlight");
49   - } else {
50   - Log.v(TAG, "This device does not support control of a flashlight");
51   - }
52   - }
53   -
54   - private FlashlightManager() {
55   - }
56   -
57   - /**
58   - * �����������ƿ���
59   - */
60   - //FIXME
61   - static void enableFlashlight() {
62   - setFlashlight(false);
63   - }
64   -
65   - static void disableFlashlight() {
66   - setFlashlight(false);
67   - }
68   -
69   - private static Object getHardwareService() {
70   - Class<?> serviceManagerClass = maybeForName("android.os.ServiceManager");
71   - if (serviceManagerClass == null) {
72   - return null;
73   - }
74   -
75   - Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class);
76   - if (getServiceMethod == null) {
77   - return null;
78   - }
79   -
80   - Object hardwareService = invoke(getServiceMethod, null, "hardware");
81   - if (hardwareService == null) {
82   - return null;
83   - }
84   -
85   - Class<?> iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub");
86   - if (iHardwareServiceStubClass == null) {
87   - return null;
88   - }
89   -
90   - Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class);
91   - if (asInterfaceMethod == null) {
92   - return null;
93   - }
94   -
95   - return invoke(asInterfaceMethod, null, hardwareService);
96   - }
97   -
98   - private static Method getSetFlashEnabledMethod(Object iHardwareService) {
99   - if (iHardwareService == null) {
100   - return null;
101   - }
102   - Class<?> proxyClass = iHardwareService.getClass();
103   - return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class);
104   - }
105   -
106   - private static Class<?> maybeForName(String name) {
107   - try {
108   - return Class.forName(name);
109   - } catch (ClassNotFoundException cnfe) {
110   - // OK
111   - return null;
112   - } catch (RuntimeException re) {
113   - Log.w(TAG, "Unexpected error while finding class " + name, re);
114   - return null;
115   - }
116   - }
117   -
118   - private static Method maybeGetMethod(Class<?> clazz, String name, Class<?>... argClasses) {
119   - try {
120   - return clazz.getMethod(name, argClasses);
121   - } catch (NoSuchMethodException nsme) {
122   - // OK
123   - return null;
124   - } catch (RuntimeException re) {
125   - Log.w(TAG, "Unexpected error while finding method " + name, re);
126   - return null;
127   - }
128   - }
129   -
130   - private static Object invoke(Method method, Object instance, Object... args) {
131   - try {
132   - return method.invoke(instance, args);
133   - } catch (IllegalAccessException e) {
134   - Log.w(TAG, "Unexpected error while invoking " + method, e);
135   - return null;
136   - } catch (InvocationTargetException e) {
137   - Log.w(TAG, "Unexpected error while invoking " + method, e.getCause());
138   - return null;
139   - } catch (RuntimeException re) {
140   - Log.w(TAG, "Unexpected error while invoking " + method, re);
141   - return null;
142   - }
143   - }
144   -
145   - private static void setFlashlight(boolean active) {
146   - if (iHardwareService != null) {
147   - invoke(setFlashEnabledMethod, iHardwareService, active);
148   - }
149   - }
150   -
151   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/PlanarYUVLuminanceSource.java deleted 100644 → 0
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.uuzuche.lib_zxing.camera;
18   -
19   -import android.graphics.Bitmap;
20   -
21   -import com.google.zxing.LuminanceSource;
22   -
23   -/**
24   - * This object extends LuminanceSource around an array of YUV data returned from the camera driver,
25   - * with the option to crop to a rectangle within the full data. This can be used to exclude
26   - * superfluous pixels around the perimeter and speed up decoding.
27   - * <p>
28   - * It works for any pixel format where the Y channel is planar and appears first, including
29   - * YCbCr_420_SP and YCbCr_422_SP.
30   - *
31   - * @author dswitkin@google.com (Daniel Switkin)
32   - */
33   -public final class PlanarYUVLuminanceSource extends LuminanceSource {
34   - private final byte[] yuvData;
35   - private final int dataWidth;
36   - private final int dataHeight;
37   - private final int left;
38   - private final int top;
39   -
40   - public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
41   - int width, int height) {
42   - super(width, height);
43   -
44   - if (left + width > dataWidth || top + height > dataHeight) {
45   - throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
46   - }
47   -
48   - this.yuvData = yuvData;
49   - this.dataWidth = dataWidth;
50   - this.dataHeight = dataHeight;
51   - this.left = left;
52   - this.top = top;
53   - }
54   -
55   - @Override
56   - public byte[] getRow(int y, byte[] row) {
57   - if (y < 0 || y >= getHeight()) {
58   - throw new IllegalArgumentException("Requested row is outside the image: " + y);
59   - }
60   - int width = getWidth();
61   - if (row == null || row.length < width) {
62   - row = new byte[width];
63   - }
64   - int offset = (y + top) * dataWidth + left;
65   - System.arraycopy(yuvData, offset, row, 0, width);
66   - return row;
67   - }
68   -
69   - @Override
70   - public byte[] getMatrix() {
71   - int width = getWidth();
72   - int height = getHeight();
73   -
74   - // If the caller asks for the entire underlying image, save the copy and give them the
75   - // original data. The docs specifically warn that result.length must be ignored.
76   - if (width == dataWidth && height == dataHeight) {
77   - return yuvData;
78   - }
79   -
80   - int area = width * height;
81   - byte[] matrix = new byte[area];
82   - int inputOffset = top * dataWidth + left;
83   -
84   - // If the width matches the full width of the underlying data, perform a single copy.
85   - if (width == dataWidth) {
86   - System.arraycopy(yuvData, inputOffset, matrix, 0, area);
87   - return matrix;
88   - }
89   -
90   - // Otherwise copy one cropped row at a time.
91   - byte[] yuv = yuvData;
92   - for (int y = 0; y < height; y++) {
93   - int outputOffset = y * width;
94   - System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
95   - inputOffset += dataWidth;
96   - }
97   - return matrix;
98   - }
99   -
100   - @Override
101   - public boolean isCropSupported() {
102   - return true;
103   - }
104   -
105   - public int getDataWidth() {
106   - return dataWidth;
107   - }
108   -
109   - public int getDataHeight() {
110   - return dataHeight;
111   - }
112   -
113   - public Bitmap renderCroppedGreyscaleBitmap() {
114   - int width = getWidth();
115   - int height = getHeight();
116   - int[] pixels = new int[width * height];
117   - byte[] yuv = yuvData;
118   - int inputOffset = top * dataWidth + left;
119   -
120   - for (int y = 0; y < height; y++) {
121   - int outputOffset = y * width;
122   - for (int x = 0; x < width; x++) {
123   - int grey = yuv[inputOffset + x] & 0xff;
124   - pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
125   - }
126   - inputOffset += dataWidth;
127   - }
128   -
129   - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
130   - bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
131   - return bitmap;
132   - }
133   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/camera/PreviewCallback.java deleted 100644 → 0
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.uuzuche.lib_zxing.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   -public final class PreviewCallback implements Camera.PreviewCallback {
26   -
27   - private static final String TAG = PreviewCallback.class.getSimpleName();
28   -
29   - private final CameraConfigurationManager configManager;
30   - private final boolean useOneShotPreviewCallback;
31   - private Handler previewHandler;
32   - private int previewMessage;
33   -
34   - PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) {
35   - this.configManager = configManager;
36   - this.useOneShotPreviewCallback = useOneShotPreviewCallback;
37   - }
38   -
39   - public void setHandler(Handler previewHandler, int previewMessage) {
40   - this.previewHandler = previewHandler;
41   - this.previewMessage = previewMessage;
42   - }
43   -
44   - public void onPreviewFrame(byte[] data, Camera camera) {
45   - Point cameraResolution = configManager.getCameraResolution();
46   - if (!useOneShotPreviewCallback) {
47   - camera.setPreviewCallback(null);
48   - }
49   - if (previewHandler != null) {
50   - Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
51   - cameraResolution.y, data);
52   - message.sendToTarget();
53   - previewHandler = null;
54   - } else {
55   - Log.d(TAG, "Got preview callback, but no handler for it");
56   - }
57   - }
58   -
59   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/CaptureActivityHandler.java deleted 100644 → 0
1   -/*
2   - * Copyright (C) 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.uuzuche.lib_zxing.decoding;
18   -
19   -import android.app.Activity;
20   -import android.content.Intent;
21   -import android.graphics.Bitmap;
22   -import android.net.Uri;
23   -import android.os.Bundle;
24   -import android.os.Handler;
25   -import android.os.Message;
26   -import android.util.Log;
27   -
28   -import com.cnlive.cloud.shanghaishop.R;
29   -import com.google.zxing.BarcodeFormat;
30   -import com.google.zxing.Result;
31   -import com.uuzuche.lib_zxing.activity.CaptureFragment;
32   -import com.uuzuche.lib_zxing.camera.CameraManager;
33   -import com.uuzuche.lib_zxing.view.ViewfinderResultPointCallback;
34   -import com.uuzuche.lib_zxing.view.ViewfinderView;
35   -
36   -import java.util.Vector;
37   -
38   -/**
39   - * This class handles all the messaging which comprises the state machine for capture.
40   - */
41   -public final class CaptureActivityHandler extends Handler {
42   -
43   - private static final String TAG = CaptureActivityHandler.class.getSimpleName();
44   -
45   - private final CaptureFragment fragment;
46   - private final DecodeThread decodeThread;
47   - private State state;
48   -
49   - private enum State {
50   - PREVIEW,
51   - SUCCESS,
52   - DONE
53   - }
54   -
55   - public CaptureActivityHandler(CaptureFragment fragment, Vector<BarcodeFormat> decodeFormats,
56   - String characterSet, ViewfinderView viewfinderView) {
57   - this.fragment = fragment;
58   - decodeThread = new DecodeThread(fragment, decodeFormats, characterSet,
59   - new ViewfinderResultPointCallback(viewfinderView));
60   - decodeThread.start();
61   - state = State.SUCCESS;
62   - // Start ourselves capturing previews and decoding.
63   - CameraManager.get().startPreview();
64   - restartPreviewAndDecode();
65   - }
66   -
67   - @Override
68   - public void handleMessage(Message message) {
69   - if (message.what == R.id.auto_focus) {
70   - //Log.d(TAG, "Got auto-focus message");
71   - // When one auto focus pass finishes, start another. This is the closest thing to
72   - // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
73   - if (state == State.PREVIEW) {
74   - CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
75   - }
76   - } else if (message.what == R.id.restart_preview) {
77   - Log.d(TAG, "Got restart preview message");
78   - restartPreviewAndDecode();
79   - } else if (message.what == R.id.decode_succeeded) {
80   - Log.d(TAG, "Got decode succeeded message");
81   - state = State.SUCCESS;
82   - Bundle bundle = message.getData();
83   -
84   - /***********************************************************************/
85   - Bitmap barcode = bundle == null ? null :
86   - (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳�
87   -
88   - fragment.handleDecode((Result) message.obj, barcode);//���ؽ��
89   - /***********************************************************************/
90   - } else if (message.what == R.id.decode_failed) {
91   - // We're decoding as fast as possible, so when one decode fails, start another.
92   - state = State.PREVIEW;
93   - CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
94   - } else if (message.what == R.id.return_scan_result) {
95   - Log.d(TAG, "Got return scan result message");
96   - fragment.getActivity().setResult(Activity.RESULT_OK, (Intent) message.obj);
97   - fragment.getActivity().finish();
98   - } else if (message.what == R.id.launch_product_query) {
99   - Log.d(TAG, "Got product query message");
100   - String url = (String) message.obj;
101   - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
102   - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
103   - fragment.getActivity().startActivity(intent);
104   - }
105   - }
106   -
107   - public void quitSynchronously() {
108   - state = State.DONE;
109   - CameraManager.get().stopPreview();
110   - Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
111   - quit.sendToTarget();
112   - try {
113   - decodeThread.join();
114   - } catch (InterruptedException e) {
115   - // continue
116   - }
117   -
118   - // Be absolutely sure we don't send any queued up messages
119   - removeMessages(R.id.decode_succeeded);
120   - removeMessages(R.id.decode_failed);
121   - }
122   -
123   - private void restartPreviewAndDecode() {
124   - if (state == State.SUCCESS) {
125   - state = State.PREVIEW;
126   - CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
127   - CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
128   - fragment.drawViewfinder();
129   - }
130   - }
131   -
132   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/DecodeFormatManager.java deleted 100644 → 0
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.uuzuche.lib_zxing.decoding;
18   -
19   -import android.content.Intent;
20   -import android.net.Uri;
21   -
22   -import com.google.zxing.BarcodeFormat;
23   -
24   -import java.util.Arrays;
25   -import java.util.List;
26   -import java.util.Vector;
27   -import java.util.regex.Pattern;
28   -
29   -public class DecodeFormatManager {
30   -
31   - private static final Pattern COMMA_PATTERN = Pattern.compile(",");
32   -
33   - public static final Vector<BarcodeFormat> PRODUCT_FORMATS;
34   - public static final Vector<BarcodeFormat> ONE_D_FORMATS;
35   - public static final Vector<BarcodeFormat> QR_CODE_FORMATS;
36   - public static final Vector<BarcodeFormat> DATA_MATRIX_FORMATS;
37   -
38   - static {
39   - PRODUCT_FORMATS = new Vector<BarcodeFormat>(5);
40   - PRODUCT_FORMATS.add(BarcodeFormat.UPC_A);
41   - PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
42   - PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
43   - PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
44   - // PRODUCT_FORMATS.add(BarcodeFormat.RSS14);
45   - ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 4);
46   - ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
47   - ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
48   - ONE_D_FORMATS.add(BarcodeFormat.CODE_93);
49   - ONE_D_FORMATS.add(BarcodeFormat.CODE_128);
50   - ONE_D_FORMATS.add(BarcodeFormat.ITF);
51   - QR_CODE_FORMATS = new Vector<BarcodeFormat>(1);
52   - QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE);
53   - DATA_MATRIX_FORMATS = new Vector<BarcodeFormat>(1);
54   - DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX);
55   - }
56   -
57   - private DecodeFormatManager() {
58   - }
59   -
60   - static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
61   - List<String> scanFormats = null;
62   - String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
63   - if (scanFormatsString != null) {
64   - scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
65   - }
66   - return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
67   - }
68   -
69   - static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
70   - List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
71   - if (formats != null && formats.size() == 1 && formats.get(0) != null) {
72   - formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
73   - }
74   - return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
75   - }
76   -
77   - private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
78   - String decodeMode) {
79   - if (scanFormats != null) {
80   - Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
81   - try {
82   - for (String format : scanFormats) {
83   - formats.add(BarcodeFormat.valueOf(format));
84   - }
85   - return formats;
86   - } catch (IllegalArgumentException iae) {
87   - // ignore it then
88   - }
89   - }
90   - if (decodeMode != null) {
91   - if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
92   - return PRODUCT_FORMATS;
93   - }
94   - if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
95   - return QR_CODE_FORMATS;
96   - }
97   - if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
98   - return DATA_MATRIX_FORMATS;
99   - }
100   - if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
101   - return ONE_D_FORMATS;
102   - }
103   - }
104   - return null;
105   - }
106   -
107   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/DecodeHandler.java deleted 100644 → 0
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.uuzuche.lib_zxing.decoding;
18   -
19   -import android.os.Bundle;
20   -import android.os.Handler;
21   -import android.os.Looper;
22   -import android.os.Message;
23   -import android.util.Log;
24   -
25   -import com.cnlive.cloud.shanghaishop.R;
26   -import com.google.zxing.BinaryBitmap;
27   -import com.google.zxing.DecodeHintType;
28   -import com.google.zxing.MultiFormatReader;
29   -import com.google.zxing.ReaderException;
30   -import com.google.zxing.Result;
31   -import com.google.zxing.common.HybridBinarizer;
32   -import com.uuzuche.lib_zxing.activity.CaptureFragment;
33   -import com.uuzuche.lib_zxing.camera.CameraManager;
34   -import com.uuzuche.lib_zxing.camera.PlanarYUVLuminanceSource;
35   -
36   -import java.util.Hashtable;
37   -
38   -final class DecodeHandler extends Handler {
39   -
40   - private static final String TAG = DecodeHandler.class.getSimpleName();
41   -
42   - private final CaptureFragment fragment;
43   - private final MultiFormatReader multiFormatReader;
44   -
45   - DecodeHandler(CaptureFragment fragment, Hashtable<DecodeHintType, Object> hints) {
46   - multiFormatReader = new MultiFormatReader();
47   - multiFormatReader.setHints(hints);
48   - this.fragment = fragment;
49   - }
50   -
51   - @Override
52   - public void handleMessage(Message message) {
53   - if (message.what == R.id.decode) {
54   - decode((byte[]) message.obj, message.arg1, message.arg2);
55   - } else if (message.what == R.id.quit) {
56   - Looper.myLooper().quit();
57   - }
58   - }
59   -
60   - /**
61   - * Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
62   - * reuse the same reader objects from one decode to the next.
63   - *
64   - * @param data The YUV preview frame.
65   - * @param width The width of the preview frame.
66   - * @param height The height of the preview frame.
67   - */
68   - private void decode(byte[] data, int width, int height) {
69   - long start = System.currentTimeMillis();
70   - Result rawResult = null;
71   -
72   - //modify here
73   - byte[] rotatedData = new byte[data.length];
74   - for (int y = 0; y < height; y++) {
75   - for (int x = 0; x < width; x++)
76   - rotatedData[x * height + height - y - 1] = data[x + y * width];
77   - }
78   - int tmp = width; // Here we are swapping, that's the difference to #11
79   - width = height;
80   - height = tmp;
81   -
82   - PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
83   - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
84   - try {
85   - rawResult = multiFormatReader.decodeWithState(bitmap);
86   - } catch (ReaderException re) {
87   - // continue
88   - } finally {
89   - multiFormatReader.reset();
90   - }
91   -
92   - if (rawResult != null) {
93   - long end = System.currentTimeMillis();
94   - Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
95   - Message message = Message.obtain(fragment.getHandler(), R.id.decode_succeeded, rawResult);
96   - Bundle bundle = new Bundle();
97   - bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
98   - message.setData(bundle);
99   - //Log.d(TAG, "Sending decode succeeded message...");
100   - message.sendToTarget();
101   - } else {
102   - Message message = Message.obtain(fragment.getHandler(), R.id.decode_failed);
103   - message.sendToTarget();
104   - }
105   - }
106   -
107   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/DecodeThread.java deleted 100644 → 0
1   -/*
2   - * Copyright (C) 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.uuzuche.lib_zxing.decoding;
18   -
19   -import android.os.Handler;
20   -import android.os.Looper;
21   -
22   -import com.google.zxing.BarcodeFormat;
23   -import com.google.zxing.DecodeHintType;
24   -import com.google.zxing.ResultPointCallback;
25   -import com.uuzuche.lib_zxing.activity.CaptureFragment;
26   -
27   -import java.util.Hashtable;
28   -import java.util.Vector;
29   -import java.util.concurrent.CountDownLatch;
30   -
31   -/**
32   - * This thread does all the heavy lifting of decoding the images.
33   - * �����߳�
34   - */
35   -final class DecodeThread extends Thread {
36   -
37   - public static final String BARCODE_BITMAP = "barcode_bitmap";
38   - private final CaptureFragment fragment;
39   - private final Hashtable<DecodeHintType, Object> hints;
40   - private Handler handler;
41   - private final CountDownLatch handlerInitLatch;
42   -
43   - DecodeThread(CaptureFragment fragment,
44   - Vector<BarcodeFormat> decodeFormats,
45   - String characterSet,
46   - ResultPointCallback resultPointCallback) {
47   -
48   - this.fragment = fragment;
49   - handlerInitLatch = new CountDownLatch(1);
50   -
51   - hints = new Hashtable<DecodeHintType, Object>(3);
52   -
53   - if (decodeFormats == null || decodeFormats.isEmpty()) {
54   - decodeFormats = new Vector<BarcodeFormat>();
55   - decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
56   - decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
57   - decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
58   - }
59   -
60   - hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
61   -
62   - if (characterSet != null) {
63   - hints.put(DecodeHintType.CHARACTER_SET, characterSet);
64   - }
65   -
66   - hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
67   - }
68   -
69   - Handler getHandler() {
70   - try {
71   - handlerInitLatch.await();
72   - } catch (InterruptedException ie) {
73   - // continue?
74   - }
75   - return handler;
76   - }
77   -
78   - @Override
79   - public void run() {
80   - Looper.prepare();
81   - handler = new DecodeHandler(fragment, hints);
82   - handlerInitLatch.countDown();
83   - Looper.loop();
84   - }
85   -
86   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/FinishListener.java deleted 100644 → 0
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.uuzuche.lib_zxing.decoding;
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   -public final class FinishListener
26   - implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable {
27   -
28   - private final Activity activityToFinish;
29   -
30   - public FinishListener(Activity activityToFinish) {
31   - this.activityToFinish = activityToFinish;
32   - }
33   -
34   - public void onCancel(DialogInterface dialogInterface) {
35   - run();
36   - }
37   -
38   - public void onClick(DialogInterface dialogInterface, int i) {
39   - run();
40   - }
41   -
42   - public void run() {
43   - activityToFinish.finish();
44   - }
45   -
46   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/InactivityTimer.java deleted 100644 → 0
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.uuzuche.lib_zxing.decoding;
18   -
19   -import android.app.Activity;
20   -
21   -import java.util.concurrent.Executors;
22   -import java.util.concurrent.ScheduledExecutorService;
23   -import java.util.concurrent.ScheduledFuture;
24   -import java.util.concurrent.ThreadFactory;
25   -import java.util.concurrent.TimeUnit;
26   -
27   -/**
28   - * Finishes an activity after a period of inactivity.
29   - */
30   -public final class InactivityTimer {
31   -
32   - private static final int INACTIVITY_DELAY_SECONDS = 5 * 60;
33   -
34   - private final ScheduledExecutorService inactivityTimer =
35   - Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory());
36   - private final Activity activity;
37   - private ScheduledFuture<?> inactivityFuture = null;
38   -
39   - public InactivityTimer(Activity activity) {
40   - this.activity = activity;
41   - onActivity();
42   - }
43   -
44   - public void onActivity() {
45   - cancel();
46   - inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
47   - INACTIVITY_DELAY_SECONDS,
48   - TimeUnit.SECONDS);
49   - }
50   -
51   - private void cancel() {
52   - if (inactivityFuture != null) {
53   - inactivityFuture.cancel(true);
54   - inactivityFuture = null;
55   - }
56   - }
57   -
58   - public void shutdown() {
59   - cancel();
60   - inactivityTimer.shutdown();
61   - }
62   -
63   - private static final class DaemonThreadFactory implements ThreadFactory {
64   - public Thread newThread(Runnable runnable) {
65   - Thread thread = new Thread(runnable);
66   - thread.setDaemon(true);
67   - return thread;
68   - }
69   - }
70   -
71   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/decoding/Intents.java deleted 100644 → 0
1   -/*
2   - * Copyright (C) 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.uuzuche.lib_zxing.decoding;
18   -
19   -/**
20   - * This class provides the constants to use when sending an Intent to Barcode Scanner.
21   - * These strings are effectively API and cannot be changed.
22   - */
23   -public final class Intents {
24   - private Intents() {
25   - }
26   -
27   - public static final class Scan {
28   - /**
29   - * Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
30   - * the results.
31   - */
32   - public static final String ACTION = "com.google.zxing.client.android.SCAN";
33   -
34   - /**
35   - * By default, sending Scan.ACTION will decode all barcodes that we understand. However it
36   - * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
37   - * one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
38   - * Optional.
39   - * <p>
40   - * Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
41   - * It is overridden by that setting.
42   - */
43   - public static final String MODE = "SCAN_MODE";
44   -
45   - /**
46   - * Comma-separated list of formats to scan for. The values must match the names of
47   - * {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
48   - * Example: "EAN_13,EAN_8,QR_CODE"
49   - * <p>
50   - * This overrides {@link #MODE}.
51   - */
52   - public static final String SCAN_FORMATS = "SCAN_FORMATS";
53   -
54   - /**
55   - * @see com.google.zxing.DecodeHintType#CHARACTER_SET
56   - */
57   - public static final String CHARACTER_SET = "CHARACTER_SET";
58   -
59   - /**
60   - * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
61   - * prices, reviews, etc. for products.
62   - */
63   - public static final String PRODUCT_MODE = "PRODUCT_MODE";
64   -
65   - /**
66   - * Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
67   - */
68   - public static final String ONE_D_MODE = "ONE_D_MODE";
69   -
70   - /**
71   - * Decode only QR codes.
72   - */
73   - public static final String QR_CODE_MODE = "QR_CODE_MODE";
74   -
75   - /**
76   - * Decode only Data Matrix codes.
77   - */
78   - public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
79   -
80   - /**
81   - * If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
82   - * requested the scan via startSubActivity(). The barcodes contents can be retrieved with
83   - * intent.getStringExtra(RESULT). If the user presses Back, the result code will be
84   - * RESULT_CANCELED.
85   - */
86   - public static final String RESULT = "SCAN_RESULT";
87   -
88   - /**
89   - * Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
90   - * See Contents.Format for possible values.
91   - */
92   - public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
93   -
94   - /**
95   - * Setting this to false will not save scanned codes in the history.
96   - */
97   - public static final String SAVE_HISTORY = "SAVE_HISTORY";
98   -
99   - private Scan() {
100   - }
101   - }
102   -
103   - public static final class Encode {
104   - /**
105   - * Send this intent to encode a piece of data as a QR code and display it full screen, so
106   - * that another person can scan the barcode from your screen.
107   - */
108   - public static final String ACTION = "com.google.zxing.client.android.ENCODE";
109   -
110   - /**
111   - * The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
112   - * Bundle, depending on the type and format specified. Non-QR Code formats should
113   - * just use a String here. For QR Code, see Contents for details.
114   - */
115   - public static final String DATA = "ENCODE_DATA";
116   -
117   - /**
118   - * The type of data being supplied if the format is QR Code. Use
119   - * Intent.putExtra(TYPE, type) with one of Contents.Type.
120   - */
121   - public static final String TYPE = "ENCODE_TYPE";
122   -
123   - /**
124   - * The barcode format to be displayed. If this isn't specified or is blank,
125   - * it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
126   - * format is one of Contents.Format.
127   - */
128   - public static final String FORMAT = "ENCODE_FORMAT";
129   -
130   - private Encode() {
131   - }
132   - }
133   -
134   - public static final class SearchBookContents {
135   - /**
136   - * Use Google Book Search to search the contents of the book provided.
137   - */
138   - public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
139   -
140   - /**
141   - * The book to search, identified by ISBN number.
142   - */
143   - public static final String ISBN = "ISBN";
144   -
145   - /**
146   - * An optional field which is the text to search for.
147   - */
148   - public static final String QUERY = "QUERY";
149   -
150   - private SearchBookContents() {
151   - }
152   - }
153   -
154   - public static final class WifiConnect {
155   - /**
156   - * Internal intent used to trigger connection to a wi-fi network.
157   - */
158   - public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
159   -
160   - /**
161   - * The network to connect to, all the configuration provided here.
162   - */
163   - public static final String SSID = "SSID";
164   -
165   - /**
166   - * The network to connect to, all the configuration provided here.
167   - */
168   - public static final String TYPE = "TYPE";
169   -
170   - /**
171   - * The network to connect to, all the configuration provided here.
172   - */
173   - public static final String PASSWORD = "PASSWORD";
174   -
175   - private WifiConnect() {
176   - }
177   - }
178   -
179   -
180   - public static final class Share {
181   - /**
182   - * Give the user a choice of items to encode as a barcode, then render it as a QR Code and
183   - * display onscreen for a friend to scan with their phone.
184   - */
185   - public static final String ACTION = "com.google.zxing.client.android.SHARE";
186   -
187   - private Share() {
188   - }
189   - }
190   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/encoding/EncodingHandler.java deleted 100644 → 0
1   -package com.uuzuche.lib_zxing.encoding;
2   -
3   -import android.graphics.Bitmap;
4   -
5   -import com.google.zxing.BarcodeFormat;
6   -import com.google.zxing.EncodeHintType;
7   -import com.google.zxing.MultiFormatWriter;
8   -import com.google.zxing.WriterException;
9   -import com.google.zxing.common.BitMatrix;
10   -
11   -import java.util.Hashtable;
12   -
13   -/**
14   - * @author Ryan Tang
15   - */
16   -public final class EncodingHandler {
17   - private static final int BLACK = 0xff000000;
18   -
19   - public static Bitmap createQRCode(String str, int widthAndHeight) throws WriterException {
20   - Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
21   - hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
22   - BitMatrix matrix = new MultiFormatWriter().encode(str,
23   - BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
24   - int width = matrix.getWidth();
25   - int height = matrix.getHeight();
26   - int[] pixels = new int[width * height];
27   -
28   - for (int y = 0; y < height; y++) {
29   - for (int x = 0; x < width; x++) {
30   - if (matrix.get(x, y)) {
31   - pixels[y * width + x] = BLACK;
32   - }
33   - }
34   - }
35   - Bitmap bitmap = Bitmap.createBitmap(width, height,
36   - Bitmap.Config.ARGB_8888);
37   - bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
38   - return bitmap;
39   - }
40   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/view/ViewfinderResultPointCallback.java deleted 100644 → 0
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.uuzuche.lib_zxing.view;
18   -
19   -import com.google.zxing.ResultPoint;
20   -import com.google.zxing.ResultPointCallback;
21   -
22   -public final class ViewfinderResultPointCallback implements ResultPointCallback {
23   -
24   - private final ViewfinderView viewfinderView;
25   -
26   - public ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
27   - this.viewfinderView = viewfinderView;
28   - }
29   -
30   - public void foundPossibleResultPoint(ResultPoint point) {
31   - viewfinderView.addPossibleResultPoint(point);
32   - }
33   -
34   -}
module/shanghaishop/src/main/java/com/uuzuche/lib_zxing/view/ViewfinderView.java deleted 100644 → 0
1   -/*
2   - * Copyright (C) 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.uuzuche.lib_zxing.view;
18   -
19   -import android.content.Context;
20   -import android.content.res.Resources;
21   -import android.content.res.TypedArray;
22   -import android.graphics.Bitmap;
23   -import android.graphics.BitmapFactory;
24   -import android.graphics.Canvas;
25   -import android.graphics.Color;
26   -import android.graphics.Paint;
27   -import android.graphics.Rect;
28   -import android.graphics.drawable.Drawable;
29   -import android.util.AttributeSet;
30   -import android.view.View;
31   -
32   -import com.cnlive.cloud.shanghaishop.R;
33   -import com.google.zxing.ResultPoint;
34   -import com.uuzuche.lib_zxing.DisplayUtil;
35   -import com.uuzuche.lib_zxing.camera.CameraManager;
36   -
37   -import java.util.Collection;
38   -import java.util.HashSet;
39   -
40   -/**
41   - * 自定义组件实现,扫描功能
42   - */
43   -public final class ViewfinderView extends View {
44   -
45   - private static final long ANIMATION_DELAY = 100L;
46   - private static final int OPAQUE = 0xFF;
47   -
48   - private final Paint paint;
49   - private Bitmap resultBitmap;
50   - private final int maskColor;
51   - private final int resultColor;
52   - private final int resultPointColor;
53   - private Collection<ResultPoint> possibleResultPoints;
54   - private Collection<ResultPoint> lastPossibleResultPoints;
55   -
56   - public ViewfinderView(Context context) {
57   - this(context, null);
58   - }
59   -
60   - public ViewfinderView(Context context, AttributeSet attrs) {
61   - this(context, attrs, -1);
62   -
63   - }
64   -
65   - public ViewfinderView(Context context, AttributeSet attrs, int defStyleAttr) {
66   - super(context, attrs, defStyleAttr);
67   - paint = new Paint();
68   - Resources resources = getResources();
69   - maskColor = resources.getColor(R.color.viewfinder_mask);
70   - resultColor = resources.getColor(R.color.result_view);
71   - resultPointColor = resources.getColor(R.color.possible_result_points);
72   - possibleResultPoints = new HashSet<>(5);
73   -
74   - scanLight = BitmapFactory.decodeResource(resources,
75   - R.drawable.scan_light);
76   -
77   - initInnerRect(context, attrs);
78   - }
79   -
80   - /**
81   - * 初始化内部框的大小
82   - *
83   - * @param context
84   - * @param attrs
85   - */
86   - private void initInnerRect(Context context, AttributeSet attrs) {
87   - TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ViewfinderView);
88   -
89   - // 扫描框距离顶部
90   - float innerMarginTop = ta.getDimension(R.styleable.ViewfinderView_inner_margintop, -1);
91   - if (innerMarginTop != -1) {
92   - CameraManager.FRAME_MARGINTOP = (int) innerMarginTop;
93   - }
94   -
95   - // 扫描框的宽度
96   - CameraManager.FRAME_WIDTH = (int) ta.getDimension(R.styleable.ViewfinderView_inner_width, DisplayUtil.screenWidthPx / 2);
97   -
98   - // 扫描框的高度
99   - CameraManager.FRAME_HEIGHT = (int) ta.getDimension(R.styleable.ViewfinderView_inner_height, DisplayUtil.screenWidthPx / 2);
100   -
101   - // 扫描框边角颜色
102   - innercornercolor = ta.getColor(R.styleable.ViewfinderView_inner_corner_color, Color.parseColor("#45DDDD"));
103   - // 扫描框边角长度
104   - innercornerlength = (int) ta.getDimension(R.styleable.ViewfinderView_inner_corner_length, 65);
105   - // 扫描框边角宽度
106   - innercornerwidth = (int) ta.getDimension(R.styleable.ViewfinderView_inner_corner_width, 15);
107   -
108   - // 扫描bitmap
109   - Drawable drawable = ta.getDrawable(R.styleable.ViewfinderView_inner_scan_bitmap);
110   - if (drawable != null) {
111   - }
112   -
113   - // 扫描控件
114   - scanLight = BitmapFactory.decodeResource(getResources(), ta.getResourceId(R.styleable.ViewfinderView_inner_scan_bitmap, R.drawable.scan_light));
115   - // 扫描速度
116   - SCAN_VELOCITY = ta.getInt(R.styleable.ViewfinderView_inner_scan_speed, 5);
117   -
118   - isCircle = ta.getBoolean(R.styleable.ViewfinderView_inner_scan_iscircle, true);
119   -
120   - ta.recycle();
121   - }
122   -
123   - @Override
124   - public void onDraw(Canvas canvas) {
125   - Rect frame = CameraManager.get().getFramingRect();
126   - if (frame == null) {
127   - return;
128   - }
129   - int width = canvas.getWidth();
130   - int height = canvas.getHeight();
131   -
132   - // Draw the exterior (i.e. outside the framing rect) darkened
133   - paint.setColor(resultBitmap != null ? resultColor : maskColor);
134   - canvas.drawRect(0, 0, width, frame.top, paint);
135   - canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
136   - canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint);
137   - canvas.drawRect(0, frame.bottom + 1, width, height, paint);
138   -
139   - if (resultBitmap != null) {
140   - // Draw the opaque result bitmap over the scanning rectangle
141   - paint.setAlpha(OPAQUE);
142   - canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
143   - } else {
144   -
145   - drawFrameBounds(canvas, frame);
146   -
147   - drawScanLight(canvas, frame);
148   -
149   - Collection<ResultPoint> currentPossible = possibleResultPoints;
150   - Collection<ResultPoint> currentLast = lastPossibleResultPoints;
151   - if (currentPossible.isEmpty()) {
152   - lastPossibleResultPoints = null;
153   - } else {
154   - possibleResultPoints = new HashSet<ResultPoint>(5);
155   - lastPossibleResultPoints = currentPossible;
156   - paint.setAlpha(OPAQUE);
157   - paint.setColor(resultPointColor);
158   -
159   - if (isCircle) {
160   - for (ResultPoint point : currentPossible) {
161   - canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 6.0f, paint);
162   - }
163   - }
164   - }
165   - if (currentLast != null) {
166   - paint.setAlpha(OPAQUE / 2);
167   - paint.setColor(resultPointColor);
168   -
169   - if (isCircle) {
170   - for (ResultPoint point : currentLast) {
171   - canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 3.0f, paint);
172   - }
173   - }
174   - }
175   -
176   - postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom);
177   - }
178   - }
179   -
180   - // 扫描线移动的y
181   - private int scanLineTop;
182   - // 扫描线移动速度
183   - private int SCAN_VELOCITY;
184   - // 扫描线
185   - private Bitmap scanLight;
186   - // 是否展示小圆点
187   - private boolean isCircle;
188   -
189   - /**
190   - * 绘制移动扫描线
191   - *
192   - * @param canvas
193   - * @param frame
194   - */
195   - private void drawScanLight(Canvas canvas, Rect frame) {
196   -
197   - if (scanLineTop == 0) {
198   - scanLineTop = frame.top;
199   - }
200   -
201   - if (scanLineTop >= frame.bottom - 30) {
202   - scanLineTop = frame.top;
203   - } else {
204   - scanLineTop += SCAN_VELOCITY;
205   - }
206   - Rect scanRect = new Rect(frame.left, scanLineTop, frame.right,
207   - scanLineTop + 30);
208   - canvas.drawBitmap(scanLight, null, scanRect, paint);
209   - }
210   -
211   -
212   - // 扫描框边角颜色
213   - private int innercornercolor;
214   - // 扫描框边角长度
215   - private int innercornerlength;
216   - // 扫描框边角宽度
217   - private int innercornerwidth;
218   -
219   - /**
220   - * 绘制取景框边框
221   - *
222   - * @param canvas
223   - * @param frame
224   - */
225   - private void drawFrameBounds(Canvas canvas, Rect frame) {
226   -
227   - /*paint.setColor(Color.WHITE);
228   - paint.setStrokeWidth(2);
229   - paint.setStyle(Paint.Style.STROKE);
230   -
231   - canvas.drawRect(frame, paint);*/
232   -
233   - paint.setColor(innercornercolor);
234   - paint.setStyle(Paint.Style.FILL);
235   -
236   - int corWidth = innercornerwidth;
237   - int corLength = innercornerlength;
238   -
239   - // 左上角
240   - canvas.drawRect(frame.left, frame.top, frame.left + corWidth, frame.top
241   - + corLength, paint);
242   - canvas.drawRect(frame.left, frame.top, frame.left
243   - + corLength, frame.top + corWidth, paint);
244   - // 右上角
245   - canvas.drawRect(frame.right - corWidth, frame.top, frame.right,
246   - frame.top + corLength, paint);
247   - canvas.drawRect(frame.right - corLength, frame.top,
248   - frame.right, frame.top + corWidth, paint);
249   - // 左下角
250   - canvas.drawRect(frame.left, frame.bottom - corLength,
251   - frame.left + corWidth, frame.bottom, paint);
252   - canvas.drawRect(frame.left, frame.bottom - corWidth, frame.left
253   - + corLength, frame.bottom, paint);
254   - // 右下角
255   - canvas.drawRect(frame.right - corWidth, frame.bottom - corLength,
256   - frame.right, frame.bottom, paint);
257   - canvas.drawRect(frame.right - corLength, frame.bottom - corWidth,
258   - frame.right, frame.bottom, paint);
259   - }
260   -
261   -
262   - public void drawViewfinder() {
263   - resultBitmap = null;
264   - invalidate();
265   - }
266   -
267   - public void addPossibleResultPoint(ResultPoint point) {
268   - possibleResultPoints.add(point);
269   - }
270   -
271   -
272   - /**
273   - * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
274   - */
275   - public static int dip2px(Context context, float dpValue) {
276   - final float scale = context.getResources().getDisplayMetrics().density;
277   - return (int) (dpValue * scale + 0.5f);
278   - }
279   -
280   -
281   -}