11 | * TODO: Replace all uses of this class before publishing your app.
12 | */
13 | public class ProxyConfigureFile {
14 |
15 | public static List
126 | * See the Android Training lesson Communicating with Other Fragments for more information.
129 | */
130 | public interface OnFragmentInteractionListener {
131 | // TODO: Update argument type and name
132 | void onFragmentInteraction(Uri uri);
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/libv2raycodescanner/src/main/java/org/kkdev/andproj/libv2raycodescanner/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) The Android Open Source Project
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 org.kkdev.andproj.libv2raycodescanner;
18 |
19 | import android.app.Activity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.util.Log;
23 | import android.view.View;
24 | import android.widget.CompoundButton;
25 | import android.widget.TextView;
26 |
27 | import com.google.android.gms.common.api.CommonStatusCodes;
28 | import com.google.android.gms.vision.barcode.Barcode;
29 |
30 | /**
31 | * Main activity demonstrating how to pass extra parameters to an activity that
32 | * reads barcodes.
33 | */
34 | public class MainActivity extends Activity implements View.OnClickListener {
35 |
36 | // use a compound button so either checkbox or switch widgets work.
37 | private CompoundButton autoFocus;
38 | private CompoundButton useFlash;
39 | private TextView statusMessage;
40 | private TextView barcodeValue;
41 |
42 | private static final int RC_BARCODE_CAPTURE = 9001;
43 | private static final String TAG = "BarcodeMain";
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | setContentView(R.layout.activity_main);
49 |
50 | statusMessage = (TextView)findViewById(R.id.status_message);
51 | barcodeValue = (TextView)findViewById(R.id.barcode_value);
52 |
53 | autoFocus = (CompoundButton) findViewById(R.id.auto_focus);
54 | useFlash = (CompoundButton) findViewById(R.id.use_flash);
55 |
56 | findViewById(R.id.read_barcode).setOnClickListener(this);
57 | startscan();
58 | }
59 |
60 | /**
61 | * Called when a view has been clicked.
62 | *
63 | * @param v The view that was clicked.
64 | */
65 | @Override
66 | public void onClick(View v) {
67 | if (v.getId() == R.id.read_barcode) {
68 | // launch barcode activity.
69 | startscan();
70 | }
71 |
72 | }
73 |
74 | private void startscan() {
75 | Intent intent = new Intent(this, BarcodeCaptureActivity.class);
76 | intent.putExtra(BarcodeCaptureActivity.AutoFocus, true);
77 | intent.putExtra(BarcodeCaptureActivity.UseFlash, false);
78 |
79 | startActivityForResult(intent, RC_BARCODE_CAPTURE);
80 | finish();
81 | }
82 |
83 | /**
84 | * Called when an activity you launched exits, giving you the requestCode
85 | * you started it with, the resultCode it returned, and any additional
86 | * data from it. The resultCode will be
87 | * {@link #RESULT_CANCELED} if the activity explicitly returned that,
88 | * didn't return any result, or crashed during its operation.
89 | * You will receive this call immediately before onResume() when your
91 | * activity is re-starting.
92 | *
34 | *
35 | * Supports scaling and mirroring of the graphics relative the camera's preview properties. The
36 | * idea is that detection items are expressed in terms of a preview size, but need to be scaled up
37 | * to the full view size, and also mirrored in the case of the front-facing camera.
38 | *
39 | * Associated {@link Graphic} items should use the following methods to convert to view coordinates
40 | * for the graphics that are drawn:
41 | *
42 | *
47 | */
48 | public class GraphicOverlay
73 | *
78 | *
79 | * @param canvas drawing canvas
80 | */
81 | public abstract void draw(Canvas canvas);
82 |
83 | /**
84 | * Adjusts a horizontal value of the supplied value from the preview scale to the view
85 | * scale.
86 | */
87 | public float scaleX(float horizontal) {
88 | return horizontal * mOverlay.mWidthScaleFactor;
89 | }
90 |
91 | /**
92 | * Adjusts a vertical value of the supplied value from the preview scale to the view scale.
93 | */
94 | public float scaleY(float vertical) {
95 | return vertical * mOverlay.mHeightScaleFactor;
96 | }
97 |
98 | /**
99 | * Adjusts the x coordinate from the preview's coordinate system to the view coordinate
100 | * system.
101 | */
102 | public float translateX(float x) {
103 | if (mOverlay.mFacing == CameraSource.CAMERA_FACING_FRONT) {
104 | return mOverlay.getWidth() - scaleX(x);
105 | } else {
106 | return scaleX(x);
107 | }
108 | }
109 |
110 | /**
111 | * Adjusts the y coordinate from the preview's coordinate system to the view coordinate
112 | * system.
113 | */
114 | public float translateY(float y) {
115 | return scaleY(y);
116 | }
117 |
118 | public void postInvalidate() {
119 | mOverlay.postInvalidate();
120 | }
121 | }
122 |
123 | public GraphicOverlay(Context context, AttributeSet attrs) {
124 | super(context, attrs);
125 | }
126 |
127 | /**
128 | * Removes all graphics from the overlay.
129 | */
130 | public void clear() {
131 | synchronized (mLock) {
132 | mGraphics.clear();
133 | }
134 | postInvalidate();
135 | }
136 |
137 | /**
138 | * Adds a graphic to the overlay.
139 | */
140 | public void add(T graphic) {
141 | synchronized (mLock) {
142 | mGraphics.add(graphic);
143 | }
144 | postInvalidate();
145 | }
146 |
147 | /**
148 | * Removes a graphic from the overlay.
149 | */
150 | public void remove(T graphic) {
151 | synchronized (mLock) {
152 | mGraphics.remove(graphic);
153 | }
154 | postInvalidate();
155 | }
156 |
157 | /**
158 | * Returns a copy (as a list) of the set of all active graphics.
159 | * @return list of all active graphics.
160 | */
161 | public List