parent
c4554f02b8
commit
07349a887e
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="edu.hzuapps.androidlabs">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" /> <!-- 震动权限 -->
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" /> <!-- 摄像头权限 -->
|
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" /> <!-- 自动聚焦权限 -->
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.AndroidLabs">
|
||||||
|
<activity android:name=".watchtv.SelectActivity" />
|
||||||
|
<activity android:name=".watchtv.MovieActivity"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden"/>
|
||||||
|
<activity android:name=".soft1914080902251.ViewByJavaActivity" />
|
||||||
|
<activity android:name=".watchtv.WatchTVActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".soft1914080902251.Soft1914080902251Activity">
|
||||||
|
|
||||||
|
<!-- <intent-filter> -->
|
||||||
|
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||||
|
<!-- </intent-filter> -->
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".MainActivity">
|
||||||
|
|
||||||
|
<!-- <intent-filter> -->
|
||||||
|
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||||
|
<!-- </intent-filter> -->
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="com.geogle.zxing.activity.CaptureActivity"/>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.dommy.qrcode.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 常量
|
||||||
|
*/
|
||||||
|
public class Constant {
|
||||||
|
// request参数
|
||||||
|
public static final int REQ_QR_CODE = 11002; // // 打开扫描界面请求码
|
||||||
|
public static final int REQ_PERM_CAMERA = 11003; // 打开摄像头
|
||||||
|
public static final int REQ_PERM_EXTERNAL_STORAGE = 11004; // 读写文件
|
||||||
|
|
||||||
|
public static final String INTENT_EXTRA_KEY_QR_SCAN = "qr_scan_result";
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.camera;
|
||||||
|
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
final class AutoFocusCallback implements Camera.AutoFocusCallback {
|
||||||
|
|
||||||
|
private static final String TAG = AutoFocusCallback.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final long AUTOFOCUS_INTERVAL_MS = 1500L;
|
||||||
|
|
||||||
|
private Handler autoFocusHandler;
|
||||||
|
private int autoFocusMessage;
|
||||||
|
|
||||||
|
void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
|
||||||
|
this.autoFocusHandler = autoFocusHandler;
|
||||||
|
this.autoFocusMessage = autoFocusMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onAutoFocus(boolean success, Camera camera) {
|
||||||
|
if (autoFocusHandler != null) {
|
||||||
|
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
|
||||||
|
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
|
||||||
|
autoFocusHandler = null;
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Got auto-focus callback, but no handler for it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,278 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.camera;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
final class CameraConfigurationManager {
|
||||||
|
|
||||||
|
private static final String TAG = CameraConfigurationManager.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final int TEN_DESIRED_ZOOM = 27;
|
||||||
|
private static final int DESIRED_SHARPNESS = 30;
|
||||||
|
|
||||||
|
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private Point screenResolution;
|
||||||
|
private Point cameraResolution;
|
||||||
|
private int previewFormat;
|
||||||
|
private String previewFormatString;
|
||||||
|
|
||||||
|
CameraConfigurationManager(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads, one time, values from the camera that are needed by the app.
|
||||||
|
*/
|
||||||
|
void initFromCameraParameters(Camera camera) {
|
||||||
|
Camera.Parameters parameters = camera.getParameters();
|
||||||
|
previewFormat = parameters.getPreviewFormat();
|
||||||
|
previewFormatString = parameters.get("preview-format");
|
||||||
|
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
|
||||||
|
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
Display display = manager.getDefaultDisplay();
|
||||||
|
screenResolution = new Point(display.getWidth(), display.getHeight());
|
||||||
|
Log.d(TAG, "Screen resolution: " + screenResolution);
|
||||||
|
|
||||||
|
//图片拉伸
|
||||||
|
Point screenResolutionForCamera = new Point();
|
||||||
|
screenResolutionForCamera.x = screenResolution.x;
|
||||||
|
screenResolutionForCamera.y = screenResolution.y;
|
||||||
|
// preview size is always something like 480*320, other 320*480
|
||||||
|
if (screenResolution.x < screenResolution.y) {
|
||||||
|
screenResolutionForCamera.x = screenResolution.y;
|
||||||
|
screenResolutionForCamera.y = screenResolution.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
|
||||||
|
Log.d(TAG, "Camera resolution: " + screenResolution);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera up to take preview images which are used for both preview and decoding.
|
||||||
|
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
|
||||||
|
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
|
||||||
|
* and the planar Y can be used for barcode scanning without a copy in some cases.
|
||||||
|
*/
|
||||||
|
void setDesiredCameraParameters(Camera camera) {
|
||||||
|
Camera.Parameters parameters = camera.getParameters();
|
||||||
|
Log.d(TAG, "Setting preview size: " + cameraResolution);
|
||||||
|
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
|
||||||
|
setFlash(parameters);
|
||||||
|
setZoom(parameters);
|
||||||
|
//setSharpness(parameters);
|
||||||
|
//modify here
|
||||||
|
camera.setDisplayOrientation(90);
|
||||||
|
camera.setParameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
Point getCameraResolution() {
|
||||||
|
return cameraResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point getScreenResolution() {
|
||||||
|
return screenResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPreviewFormat() {
|
||||||
|
return previewFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getPreviewFormatString() {
|
||||||
|
return previewFormatString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) {
|
||||||
|
|
||||||
|
String previewSizeValueString = parameters.get("preview-size-values");
|
||||||
|
// saw this on Xperia
|
||||||
|
if (previewSizeValueString == null) {
|
||||||
|
previewSizeValueString = parameters.get("preview-size-value");
|
||||||
|
}
|
||||||
|
|
||||||
|
Point cameraResolution = null;
|
||||||
|
|
||||||
|
if (previewSizeValueString != null) {
|
||||||
|
Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString);
|
||||||
|
cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cameraResolution == null) {
|
||||||
|
// Ensure that the camera resolution is a multiple of 8, as the screen may not be.
|
||||||
|
cameraResolution = new Point(
|
||||||
|
(screenResolution.x >> 3) << 3,
|
||||||
|
(screenResolution.y >> 3) << 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cameraResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
|
||||||
|
int bestX = 0;
|
||||||
|
int bestY = 0;
|
||||||
|
int diff = Integer.MAX_VALUE;
|
||||||
|
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
|
||||||
|
|
||||||
|
previewSize = previewSize.trim();
|
||||||
|
int dimPosition = previewSize.indexOf('x');
|
||||||
|
if (dimPosition < 0) {
|
||||||
|
Log.w(TAG, "Bad preview-size: " + previewSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newX;
|
||||||
|
int newY;
|
||||||
|
try {
|
||||||
|
newX = Integer.parseInt(previewSize.substring(0, dimPosition));
|
||||||
|
newY = Integer.parseInt(previewSize.substring(dimPosition + 1));
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad preview-size: " + previewSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y);
|
||||||
|
if (newDiff == 0) {
|
||||||
|
bestX = newX;
|
||||||
|
bestY = newY;
|
||||||
|
break;
|
||||||
|
} else if (newDiff < diff) {
|
||||||
|
bestX = newX;
|
||||||
|
bestY = newY;
|
||||||
|
diff = newDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestX > 0 && bestY > 0) {
|
||||||
|
return new Point(bestX, bestY);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int findBestMotZoomValue(CharSequence stringValues, int tenDesiredZoom) {
|
||||||
|
int tenBestValue = 0;
|
||||||
|
for (String stringValue : COMMA_PATTERN.split(stringValues)) {
|
||||||
|
stringValue = stringValue.trim();
|
||||||
|
double value;
|
||||||
|
try {
|
||||||
|
value = Double.parseDouble(stringValue);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
return tenDesiredZoom;
|
||||||
|
}
|
||||||
|
int tenValue = (int) (10.0 * value);
|
||||||
|
if (Math.abs(tenDesiredZoom - value) < Math.abs(tenDesiredZoom - tenBestValue)) {
|
||||||
|
tenBestValue = tenValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tenBestValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFlash(Camera.Parameters parameters) {
|
||||||
|
// FIXME: This is a hack to turn the flash off on the Samsung Galaxy.
|
||||||
|
// And this is a hack-hack to work around a different value on the Behold II
|
||||||
|
// Restrict Behold II check to Cupcake, per Samsung's advice
|
||||||
|
//if (Build.MODEL.contains("Behold II") &&
|
||||||
|
// CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
|
||||||
|
if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
|
||||||
|
parameters.set("flash-value", 1);
|
||||||
|
} else {
|
||||||
|
parameters.set("flash-value", 2);
|
||||||
|
}
|
||||||
|
// This is the standard setting to turn the flash off that all devices should honor.
|
||||||
|
parameters.set("flash-mode", "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setZoom(Camera.Parameters parameters) {
|
||||||
|
|
||||||
|
String zoomSupportedString = parameters.get("zoom-supported");
|
||||||
|
if (zoomSupportedString != null && !Boolean.parseBoolean(zoomSupportedString)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tenDesiredZoom = TEN_DESIRED_ZOOM;
|
||||||
|
|
||||||
|
String maxZoomString = parameters.get("max-zoom");
|
||||||
|
if (maxZoomString != null) {
|
||||||
|
try {
|
||||||
|
int tenMaxZoom = (int) (10.0 * Double.parseDouble(maxZoomString));
|
||||||
|
if (tenDesiredZoom > tenMaxZoom) {
|
||||||
|
tenDesiredZoom = tenMaxZoom;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad max-zoom: " + maxZoomString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String takingPictureZoomMaxString = parameters.get("taking-picture-zoom-max");
|
||||||
|
if (takingPictureZoomMaxString != null) {
|
||||||
|
try {
|
||||||
|
int tenMaxZoom = Integer.parseInt(takingPictureZoomMaxString);
|
||||||
|
if (tenDesiredZoom > tenMaxZoom) {
|
||||||
|
tenDesiredZoom = tenMaxZoom;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad taking-picture-zoom-max: " + takingPictureZoomMaxString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String motZoomValuesString = parameters.get("mot-zoom-values");
|
||||||
|
if (motZoomValuesString != null) {
|
||||||
|
tenDesiredZoom = findBestMotZoomValue(motZoomValuesString, tenDesiredZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
String motZoomStepString = parameters.get("mot-zoom-step");
|
||||||
|
if (motZoomStepString != null) {
|
||||||
|
try {
|
||||||
|
double motZoomStep = Double.parseDouble(motZoomStepString.trim());
|
||||||
|
int tenZoomStep = (int) (10.0 * motZoomStep);
|
||||||
|
if (tenZoomStep > 1) {
|
||||||
|
tenDesiredZoom -= tenDesiredZoom % tenZoomStep;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
// continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set zoom. This helps encourage the user to pull back.
|
||||||
|
// Some devices like the Behold have a zoom parameter
|
||||||
|
if (maxZoomString != null || motZoomValuesString != null) {
|
||||||
|
parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most devices, like the Hero, appear to expose this zoom parameter.
|
||||||
|
// It takes on values like "27" which appears to mean 2.7x zoom
|
||||||
|
if (takingPictureZoomMaxString != null) {
|
||||||
|
parameters.set("taking-picture-zoom", tenDesiredZoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDesiredSharpness() {
|
||||||
|
return DESIRED_SHARPNESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.camera;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import com.google.zxing.LuminanceSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
|
||||||
|
* with the option to crop to a rectangle within the full data. This can be used to exclude
|
||||||
|
* superfluous pixels around the perimeter and speed up decoding.
|
||||||
|
*
|
||||||
|
* It works for any pixel format where the Y channel is planar and appears first, including
|
||||||
|
* YCbCr_420_SP and YCbCr_422_SP.
|
||||||
|
*
|
||||||
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
|
*/
|
||||||
|
public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
||||||
|
private final byte[] yuvData;
|
||||||
|
private final int dataWidth;
|
||||||
|
private final int dataHeight;
|
||||||
|
private final int left;
|
||||||
|
private final int top;
|
||||||
|
|
||||||
|
public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
|
||||||
|
int width, int height) {
|
||||||
|
super(width, height);
|
||||||
|
|
||||||
|
if (left + width > dataWidth || top + height > dataHeight) {
|
||||||
|
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.yuvData = yuvData;
|
||||||
|
this.dataWidth = dataWidth;
|
||||||
|
this.dataHeight = dataHeight;
|
||||||
|
this.left = left;
|
||||||
|
this.top = top;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getRow(int y, byte[] row) {
|
||||||
|
if (y < 0 || y >= getHeight()) {
|
||||||
|
throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
||||||
|
}
|
||||||
|
int width = getWidth();
|
||||||
|
if (row == null || row.length < width) {
|
||||||
|
row = new byte[width];
|
||||||
|
}
|
||||||
|
int offset = (y + top) * dataWidth + left;
|
||||||
|
System.arraycopy(yuvData, offset, row, 0, width);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getMatrix() {
|
||||||
|
int width = getWidth();
|
||||||
|
int height = getHeight();
|
||||||
|
|
||||||
|
// If the caller asks for the entire underlying image, save the copy and give them the
|
||||||
|
// original data. The docs specifically warn that result.length must be ignored.
|
||||||
|
if (width == dataWidth && height == dataHeight) {
|
||||||
|
return yuvData;
|
||||||
|
}
|
||||||
|
|
||||||
|
int area = width * height;
|
||||||
|
byte[] matrix = new byte[area];
|
||||||
|
int inputOffset = top * dataWidth + left;
|
||||||
|
|
||||||
|
// If the width matches the full width of the underlying data, perform a single copy.
|
||||||
|
if (width == dataWidth) {
|
||||||
|
System.arraycopy(yuvData, inputOffset, matrix, 0, area);
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise copy one cropped row at a time.
|
||||||
|
byte[] yuv = yuvData;
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
int outputOffset = y * width;
|
||||||
|
System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
|
||||||
|
inputOffset += dataWidth;
|
||||||
|
}
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCropSupported() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataWidth() {
|
||||||
|
return dataWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataHeight() {
|
||||||
|
return dataHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap renderCroppedGreyscaleBitmap() {
|
||||||
|
int width = getWidth();
|
||||||
|
int height = getHeight();
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
byte[] yuv = yuvData;
|
||||||
|
int inputOffset = top * dataWidth + left;
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
int outputOffset = y * width;
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
int grey = yuv[inputOffset + x] & 0xff;
|
||||||
|
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
|
||||||
|
}
|
||||||
|
inputOffset += dataWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.camera;
|
||||||
|
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
final class PreviewCallback implements Camera.PreviewCallback {
|
||||||
|
|
||||||
|
private static final String TAG = PreviewCallback.class.getSimpleName();
|
||||||
|
|
||||||
|
private final CameraConfigurationManager configManager;
|
||||||
|
private final boolean useOneShotPreviewCallback;
|
||||||
|
private Handler previewHandler;
|
||||||
|
private int previewMessage;
|
||||||
|
|
||||||
|
PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) {
|
||||||
|
this.configManager = configManager;
|
||||||
|
this.useOneShotPreviewCallback = useOneShotPreviewCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHandler(Handler previewHandler, int previewMessage) {
|
||||||
|
this.previewHandler = previewHandler;
|
||||||
|
this.previewMessage = previewMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||||
|
Point cameraResolution = configManager.getCameraResolution();
|
||||||
|
if (!useOneShotPreviewCallback) {
|
||||||
|
camera.setPreviewCallback(null);
|
||||||
|
}
|
||||||
|
if (previewHandler != null) {
|
||||||
|
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
|
||||||
|
cameraResolution.y, data);
|
||||||
|
message.sendToTarget();
|
||||||
|
previewHandler = null;
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Got preview callback, but no handler for it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package com.geogle.zxing.decoding;/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
final class DecodeFormatManager {
|
||||||
|
|
||||||
|
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||||
|
|
||||||
|
static final Vector<BarcodeFormat> PRODUCT_FORMATS;
|
||||||
|
static final Vector<BarcodeFormat> ONE_D_FORMATS;
|
||||||
|
static final Vector<BarcodeFormat> QR_CODE_FORMATS;
|
||||||
|
static final Vector<BarcodeFormat> DATA_MATRIX_FORMATS;
|
||||||
|
static {
|
||||||
|
PRODUCT_FORMATS = new Vector<BarcodeFormat>(5);
|
||||||
|
PRODUCT_FORMATS.add(BarcodeFormat.UPC_A);
|
||||||
|
PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
|
||||||
|
PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
|
||||||
|
PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
|
||||||
|
ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 4);
|
||||||
|
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
|
||||||
|
ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
|
||||||
|
ONE_D_FORMATS.add(BarcodeFormat.CODE_93);
|
||||||
|
ONE_D_FORMATS.add(BarcodeFormat.CODE_128);
|
||||||
|
ONE_D_FORMATS.add(BarcodeFormat.ITF);
|
||||||
|
QR_CODE_FORMATS = new Vector<BarcodeFormat>(1);
|
||||||
|
QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE);
|
||||||
|
DATA_MATRIX_FORMATS = new Vector<BarcodeFormat>(1);
|
||||||
|
DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DecodeFormatManager() {}
|
||||||
|
|
||||||
|
static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
|
||||||
|
List<String> scanFormats = null;
|
||||||
|
String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
|
||||||
|
if (scanFormatsString != null) {
|
||||||
|
scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
|
||||||
|
}
|
||||||
|
return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
|
||||||
|
List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
|
||||||
|
if (formats != null && formats.size() == 1 && formats.get(0) != null){
|
||||||
|
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
|
||||||
|
}
|
||||||
|
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
|
||||||
|
String decodeMode) {
|
||||||
|
if (scanFormats != null) {
|
||||||
|
Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
|
||||||
|
try {
|
||||||
|
for (String format : scanFormats) {
|
||||||
|
formats.add(BarcodeFormat.valueOf(format));
|
||||||
|
}
|
||||||
|
return formats;
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// ignore it then
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (decodeMode != null) {
|
||||||
|
if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
|
||||||
|
return PRODUCT_FORMATS;
|
||||||
|
}
|
||||||
|
if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
|
||||||
|
return QR_CODE_FORMATS;
|
||||||
|
}
|
||||||
|
if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
|
||||||
|
return DATA_MATRIX_FORMATS;
|
||||||
|
}
|
||||||
|
if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
|
||||||
|
return ONE_D_FORMATS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
package com.geogle.zxing.decoding;/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
|
import com.geogle.zxing.camera.PlanarYUVLuminanceSource;
|
||||||
|
import com.google.zxing.BinaryBitmap;
|
||||||
|
import com.google.zxing.DecodeHintType;
|
||||||
|
import com.google.zxing.MultiFormatReader;
|
||||||
|
import com.google.zxing.ReaderException;
|
||||||
|
import com.google.zxing.Result;
|
||||||
|
|
||||||
|
import com.geogle.zxing.camera.CameraManager;
|
||||||
|
|
||||||
|
import com.google.zxing.common.HybridBinarizer;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import com.geogle.zxing.activity.CaptureActivity;
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
|
||||||
|
|
||||||
|
final class DecodeHandler extends Handler {
|
||||||
|
|
||||||
|
private static final String TAG = DecodeHandler.class.getSimpleName();
|
||||||
|
|
||||||
|
private final CaptureActivity activity;
|
||||||
|
private final MultiFormatReader multiFormatReader;
|
||||||
|
|
||||||
|
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
|
||||||
|
multiFormatReader = new MultiFormatReader();
|
||||||
|
multiFormatReader.setHints(hints);
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message message) {
|
||||||
|
switch (message.what) {
|
||||||
|
case R.id.decode:
|
||||||
|
//Log.d(TAG, "Got decode message");
|
||||||
|
decode((byte[]) message.obj, message.arg1, message.arg2);
|
||||||
|
break;
|
||||||
|
case R.id.quit:
|
||||||
|
Looper.myLooper().quit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
|
||||||
|
* reuse the same reader objects from one decode to the next.
|
||||||
|
*
|
||||||
|
* @param data The YUV preview frame.
|
||||||
|
* @param width The width of the preview frame.
|
||||||
|
* @param height The height of the preview frame.
|
||||||
|
*/
|
||||||
|
private void decode(byte[] data, int width, int height) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
Result rawResult = null;
|
||||||
|
|
||||||
|
//modify here
|
||||||
|
byte[] rotatedData = new byte[data.length];
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
rotatedData[x * height + height - y - 1] = data[x + y * width];
|
||||||
|
}
|
||||||
|
int tmp = width; // Here we are swapping, that's the difference to #11
|
||||||
|
width = height;
|
||||||
|
height = tmp;
|
||||||
|
|
||||||
|
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
|
||||||
|
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||||
|
try {
|
||||||
|
rawResult = multiFormatReader.decodeWithState(bitmap);
|
||||||
|
} catch (ReaderException re) {
|
||||||
|
// continue
|
||||||
|
} finally {
|
||||||
|
multiFormatReader.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rawResult != null) {
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
|
||||||
|
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
|
||||||
|
message.setData(bundle);
|
||||||
|
//Log.d(TAG, "Sending decode succeeded message...");
|
||||||
|
message.sendToTarget();
|
||||||
|
} else {
|
||||||
|
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed);
|
||||||
|
message.sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.decoding;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple listener used to exit the app in a few cases.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class FinishListener
|
||||||
|
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable {
|
||||||
|
|
||||||
|
private final Activity activityToFinish;
|
||||||
|
|
||||||
|
public FinishListener(Activity activityToFinish) {
|
||||||
|
this.activityToFinish = activityToFinish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCancel(DialogInterface dialogInterface) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
activityToFinish.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.decoding;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finishes an activity after a period of inactivity.
|
||||||
|
*/
|
||||||
|
public final class InactivityTimer {
|
||||||
|
|
||||||
|
private static final int INACTIVITY_DELAY_SECONDS = 5 * 60;
|
||||||
|
|
||||||
|
private final ScheduledExecutorService inactivityTimer =
|
||||||
|
Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory());
|
||||||
|
private final Activity activity;
|
||||||
|
private ScheduledFuture<?> inactivityFuture = null;
|
||||||
|
|
||||||
|
public InactivityTimer(Activity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
onActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onActivity() {
|
||||||
|
cancel();
|
||||||
|
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
|
||||||
|
INACTIVITY_DELAY_SECONDS,
|
||||||
|
TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancel() {
|
||||||
|
if (inactivityFuture != null) {
|
||||||
|
inactivityFuture.cancel(true);
|
||||||
|
inactivityFuture = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
cancel();
|
||||||
|
inactivityTimer.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class DaemonThreadFactory implements ThreadFactory {
|
||||||
|
public Thread newThread(Runnable runnable) {
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.decoding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides the constants to use when sending an Intent to Barcode Scanner.
|
||||||
|
* These strings are effectively API and cannot be changed.
|
||||||
|
*/
|
||||||
|
public final class Intents {
|
||||||
|
private Intents() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Scan {
|
||||||
|
/**
|
||||||
|
* Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
|
||||||
|
* the results.
|
||||||
|
*/
|
||||||
|
public static final String ACTION = "com.google.zxing.client.android.SCAN";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, sending Scan.ACTION will decode all barcodes that we understand. However it
|
||||||
|
* may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
|
||||||
|
* one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
|
||||||
|
* Optional.
|
||||||
|
*
|
||||||
|
* Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
|
||||||
|
* It is overridden by that setting.
|
||||||
|
*/
|
||||||
|
public static final String MODE = "SCAN_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comma-separated list of formats to scan for. The values must match the names of
|
||||||
|
* {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
|
||||||
|
* Example: "EAN_13,EAN_8,QR_CODE"
|
||||||
|
*
|
||||||
|
* This overrides {@link #MODE}.
|
||||||
|
*/
|
||||||
|
public static final String SCAN_FORMATS = "SCAN_FORMATS";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.google.zxing.DecodeHintType#CHARACTER_SET
|
||||||
|
*/
|
||||||
|
public static final String CHARACTER_SET = "CHARACTER_SET";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
|
||||||
|
* prices, reviews, etc. for products.
|
||||||
|
*/
|
||||||
|
public static final String PRODUCT_MODE = "PRODUCT_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
|
||||||
|
*/
|
||||||
|
public static final String ONE_D_MODE = "ONE_D_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode only QR codes.
|
||||||
|
*/
|
||||||
|
public static final String QR_CODE_MODE = "QR_CODE_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode only Data Matrix codes.
|
||||||
|
*/
|
||||||
|
public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
|
||||||
|
* requested the scan via startSubActivity(). The barcodes contents can be retrieved with
|
||||||
|
* intent.getStringExtra(RESULT). If the user presses Back, the result code will be
|
||||||
|
* RESULT_CANCELED.
|
||||||
|
*/
|
||||||
|
public static final String RESULT = "SCAN_RESULT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
|
||||||
|
* See Contents.Format for possible values.
|
||||||
|
*/
|
||||||
|
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting this to false will not save scanned codes in the history.
|
||||||
|
*/
|
||||||
|
public static final String SAVE_HISTORY = "SAVE_HISTORY";
|
||||||
|
|
||||||
|
private Scan() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Encode {
|
||||||
|
/**
|
||||||
|
* Send this intent to encode a piece of data as a QR code and display it full screen, so
|
||||||
|
* that another person can scan the barcode from your screen.
|
||||||
|
*/
|
||||||
|
public static final String ACTION = "com.google.zxing.client.android.ENCODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
|
||||||
|
* Bundle, depending on the type and format specified. Non-QR Code formats should
|
||||||
|
* just use a String here. For QR Code, see Contents for details.
|
||||||
|
*/
|
||||||
|
public static final String DATA = "ENCODE_DATA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of data being supplied if the format is QR Code. Use
|
||||||
|
* Intent.putExtra(TYPE, type) with one of Contents.Type.
|
||||||
|
*/
|
||||||
|
public static final String TYPE = "ENCODE_TYPE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The barcode format to be displayed. If this isn't specified or is blank,
|
||||||
|
* it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
|
||||||
|
* format is one of Contents.Format.
|
||||||
|
*/
|
||||||
|
public static final String FORMAT = "ENCODE_FORMAT";
|
||||||
|
|
||||||
|
private Encode() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class SearchBookContents {
|
||||||
|
/**
|
||||||
|
* Use Google Book Search to search the contents of the book provided.
|
||||||
|
*/
|
||||||
|
public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The book to search, identified by ISBN number.
|
||||||
|
*/
|
||||||
|
public static final String ISBN = "ISBN";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional field which is the text to search for.
|
||||||
|
*/
|
||||||
|
public static final String QUERY = "QUERY";
|
||||||
|
|
||||||
|
private SearchBookContents() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class WifiConnect {
|
||||||
|
/**
|
||||||
|
* Internal intent used to trigger connection to a wi-fi network.
|
||||||
|
*/
|
||||||
|
public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network to connect to, all the configuration provided here.
|
||||||
|
*/
|
||||||
|
public static final String SSID = "SSID";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network to connect to, all the configuration provided here.
|
||||||
|
*/
|
||||||
|
public static final String TYPE = "TYPE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network to connect to, all the configuration provided here.
|
||||||
|
*/
|
||||||
|
public static final String PASSWORD = "PASSWORD";
|
||||||
|
|
||||||
|
private WifiConnect() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Share {
|
||||||
|
/**
|
||||||
|
* Give the user a choice of items to encode as a barcode, then render it as a QR Code and
|
||||||
|
* display onscreen for a friend to scan with their phone.
|
||||||
|
*/
|
||||||
|
public static final String ACTION = "com.google.zxing.client.android.SHARE";
|
||||||
|
|
||||||
|
private Share() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.decoding;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
|
||||||
|
import com.google.zxing.LuminanceSource;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to help decode images from files which arrive as RGB data
|
||||||
|
* from Android bitmaps. It does not support cropping or rotation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class RGBLuminanceSource extends LuminanceSource {
|
||||||
|
|
||||||
|
private final byte[] luminances;
|
||||||
|
|
||||||
|
public RGBLuminanceSource(String path) throws FileNotFoundException {
|
||||||
|
this(loadBitmap(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RGBLuminanceSource(Bitmap bitmap) {
|
||||||
|
super(bitmap.getWidth(), bitmap.getHeight());
|
||||||
|
|
||||||
|
int width = bitmap.getWidth();
|
||||||
|
int height = bitmap.getHeight();
|
||||||
|
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||||
|
|
||||||
|
// In order to measure pure decoding speed, we convert the entire image
|
||||||
|
// to a greyscale array
|
||||||
|
// up front, which is the same as the Y channel of the
|
||||||
|
// YUVLuminanceSource in the real app.
|
||||||
|
luminances = new byte[width * height];
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
int offset = y * width;
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
int pixel = pixels[offset + x];
|
||||||
|
int r = (pixel >> 16) & 0xff;
|
||||||
|
int g = (pixel >> 8) & 0xff;
|
||||||
|
int b = pixel & 0xff;
|
||||||
|
if (r == g && g == b) {
|
||||||
|
// Image is already greyscale, so pick any channel.
|
||||||
|
luminances[offset + x] = (byte) r;
|
||||||
|
} else {
|
||||||
|
// Calculate luminance cheaply, favoring green.
|
||||||
|
luminances[offset + x] = (byte) ((r + g + g + b) >> 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getRow(int y, byte[] row) {
|
||||||
|
if (y < 0 || y >= getHeight()) {
|
||||||
|
throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
||||||
|
}
|
||||||
|
int width = getWidth();
|
||||||
|
if (row == null || row.length < width) {
|
||||||
|
row = new byte[width];
|
||||||
|
}
|
||||||
|
|
||||||
|
System.arraycopy(luminances, y * width, row, 0, width);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since this class does not support cropping, the underlying byte array
|
||||||
|
// already contains
|
||||||
|
// exactly what the caller is asking for, so give it to them without a copy.
|
||||||
|
@Override
|
||||||
|
public byte[] getMatrix() {
|
||||||
|
return luminances;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Bitmap loadBitmap(String path) throws FileNotFoundException {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(path);
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new FileNotFoundException("Couldn't open " + path);
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.view;
|
||||||
|
|
||||||
|
import com.google.zxing.ResultPoint;
|
||||||
|
import com.google.zxing.ResultPointCallback;
|
||||||
|
|
||||||
|
public final class ViewfinderResultPointCallback implements ResultPointCallback {
|
||||||
|
private final ViewfinderView viewfinderView;
|
||||||
|
|
||||||
|
public ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
|
||||||
|
this.viewfinderView = viewfinderView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void foundPossibleResultPoint(ResultPoint point) {
|
||||||
|
viewfinderView.addPossibleResultPoint(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,286 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.geogle.zxing.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.ComposeShader;
|
||||||
|
import android.graphics.LinearGradient;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.RadialGradient;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.SweepGradient;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.zxing.ResultPoint;
|
||||||
|
import com.geogle.zxing.camera.CameraManager;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
|
||||||
|
* transparency outside it, as well as the laser scanner animation and result points.
|
||||||
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
|
*/
|
||||||
|
public final class ViewfinderView extends View {
|
||||||
|
|
||||||
|
private static final int[] SCANNER_ALPHA = {0, 64, 128, 192, 255, 192, 128, 64};
|
||||||
|
private static final long ANIMATION_DELAY = 10L;
|
||||||
|
private static final int OPAQUE = 0xFF;
|
||||||
|
private static final int CORNER_RECT_WIDTH = 8; //扫描区边角的宽
|
||||||
|
private static final int CORNER_RECT_HEIGHT = 40; //扫描区边角的高
|
||||||
|
private static final int SCANNER_LINE_MOVE_DISTANCE = 5; //扫描线移动距离
|
||||||
|
private static final int SCANNER_LINE_HEIGHT = 10; //扫描线宽度
|
||||||
|
|
||||||
|
private final Paint paint;
|
||||||
|
private Bitmap resultBitmap;
|
||||||
|
//模糊区域颜色
|
||||||
|
private final int maskColor;
|
||||||
|
private final int resultColor;
|
||||||
|
//扫描区域边框颜色
|
||||||
|
private final int frameColor;
|
||||||
|
//扫描线颜色
|
||||||
|
private final int laserColor;
|
||||||
|
//四角颜色
|
||||||
|
private final int cornerColor;
|
||||||
|
//扫描点的颜色
|
||||||
|
private final int resultPointColor;
|
||||||
|
private int scannerAlpha;
|
||||||
|
//扫描区域提示文本
|
||||||
|
private final String labelText;
|
||||||
|
//扫描区域提示文本颜色
|
||||||
|
private final int labelTextColor;
|
||||||
|
private final float labelTextSize;
|
||||||
|
|
||||||
|
public static int scannerStart = 0;
|
||||||
|
public static int scannerEnd = 0;
|
||||||
|
|
||||||
|
private Collection<ResultPoint> possibleResultPoints;
|
||||||
|
private Collection<ResultPoint> lastPossibleResultPoints;
|
||||||
|
|
||||||
|
// This constructor is used when the class is built from an XML resource.
|
||||||
|
public ViewfinderView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
|
||||||
|
//初始化自定义属性信息
|
||||||
|
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ViewfinderView);
|
||||||
|
laserColor = array.getColor(R.styleable.ViewfinderView_laser_color, 0x00FF00);
|
||||||
|
cornerColor = array.getColor(R.styleable.ViewfinderView_corner_color, 0x00FF00);
|
||||||
|
frameColor = array.getColor(R.styleable.ViewfinderView_frame_color, 0xFFFFFF);
|
||||||
|
resultPointColor = array.getColor(R.styleable.ViewfinderView_result_point_color, 0xC0FFFF00);
|
||||||
|
maskColor = array.getColor(R.styleable.ViewfinderView_mask_color, 0x60000000);
|
||||||
|
resultColor = array.getColor(R.styleable.ViewfinderView_result_color, 0xB0000000);
|
||||||
|
labelTextColor = array.getColor(R.styleable.ViewfinderView_label_text_color, 0x90FFFFFF);
|
||||||
|
labelText = array.getString(R.styleable.ViewfinderView_label_text);
|
||||||
|
labelTextSize = array.getFloat(R.styleable.ViewfinderView_label_text_size, 36f);
|
||||||
|
|
||||||
|
// Initialize these once for performance rather than calling them every time in onDraw().
|
||||||
|
paint = new Paint();
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
scannerAlpha = 0;
|
||||||
|
possibleResultPoints = new HashSet<ResultPoint>(5);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas canvas) {
|
||||||
|
Rect frame = CameraManager.get().getFramingRect();
|
||||||
|
if (frame == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(scannerStart == 0 || scannerEnd == 0) {
|
||||||
|
scannerStart = frame.top;
|
||||||
|
scannerEnd = frame.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = canvas.getWidth();
|
||||||
|
int height = canvas.getHeight();
|
||||||
|
// Draw the exterior (i.e. outside the framing rect) darkened
|
||||||
|
drawExterior(canvas, frame, width, height);
|
||||||
|
|
||||||
|
|
||||||
|
if (resultBitmap != null) {
|
||||||
|
// Draw the opaque result bitmap over the scanning rectangle
|
||||||
|
paint.setAlpha(OPAQUE);
|
||||||
|
canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
|
||||||
|
} else {
|
||||||
|
// Draw a two pixel solid black border inside the framing rect
|
||||||
|
drawFrame(canvas, frame);
|
||||||
|
// 绘制边角
|
||||||
|
drawCorner(canvas, frame);
|
||||||
|
//绘制提示信息
|
||||||
|
drawTextInfo(canvas, frame);
|
||||||
|
// Draw a red "laser scanner" line through the middle to show decoding is active
|
||||||
|
drawLaserScanner(canvas, frame);
|
||||||
|
|
||||||
|
Collection<ResultPoint> currentPossible = possibleResultPoints;
|
||||||
|
Collection<ResultPoint> currentLast = lastPossibleResultPoints;
|
||||||
|
if (currentPossible.isEmpty()) {
|
||||||
|
lastPossibleResultPoints = null;
|
||||||
|
} else {
|
||||||
|
possibleResultPoints = new HashSet<ResultPoint>(5);
|
||||||
|
lastPossibleResultPoints = currentPossible;
|
||||||
|
paint.setAlpha(OPAQUE);
|
||||||
|
paint.setColor(resultPointColor);
|
||||||
|
for (ResultPoint point : currentPossible) {
|
||||||
|
canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 6.0f, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentLast != null) {
|
||||||
|
paint.setAlpha(OPAQUE / 2);
|
||||||
|
paint.setColor(resultPointColor);
|
||||||
|
for (ResultPoint point : currentLast) {
|
||||||
|
canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 3.0f, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request another update at the animation interval, but only repaint the laser line,
|
||||||
|
// not the entire viewfinder mask.
|
||||||
|
//指定重绘区域,该方法会在子线程中执行
|
||||||
|
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//绘制文本
|
||||||
|
private void drawTextInfo(Canvas canvas, Rect frame) {
|
||||||
|
paint.setColor(labelTextColor);
|
||||||
|
paint.setTextSize(labelTextSize);
|
||||||
|
paint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
canvas.drawText(labelText, frame.left + frame.width() / 2, frame.bottom + CORNER_RECT_HEIGHT * 1.5f, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//绘制边角
|
||||||
|
private void drawCorner(Canvas canvas, Rect frame) {
|
||||||
|
paint.setColor(cornerColor);
|
||||||
|
//左上
|
||||||
|
canvas.drawRect(frame.left, frame.top, frame.left + CORNER_RECT_WIDTH, frame.top + CORNER_RECT_HEIGHT, paint);
|
||||||
|
canvas.drawRect(frame.left, frame.top, frame.left + CORNER_RECT_HEIGHT, frame.top + CORNER_RECT_WIDTH, paint);
|
||||||
|
//右上
|
||||||
|
canvas.drawRect(frame.right - CORNER_RECT_WIDTH, frame.top, frame.right, frame.top + CORNER_RECT_HEIGHT, paint);
|
||||||
|
canvas.drawRect(frame.right - CORNER_RECT_HEIGHT, frame.top, frame.right, frame.top + CORNER_RECT_WIDTH, paint);
|
||||||
|
//左下
|
||||||
|
canvas.drawRect(frame.left, frame.bottom - CORNER_RECT_WIDTH, frame.left + CORNER_RECT_HEIGHT, frame.bottom, paint);
|
||||||
|
canvas.drawRect(frame.left, frame.bottom - CORNER_RECT_HEIGHT, frame.left + CORNER_RECT_WIDTH, frame.bottom, paint);
|
||||||
|
//右下
|
||||||
|
canvas.drawRect(frame.right - CORNER_RECT_WIDTH, frame.bottom - CORNER_RECT_HEIGHT, frame.right, frame.bottom, paint);
|
||||||
|
canvas.drawRect(frame.right - CORNER_RECT_HEIGHT, frame.bottom - CORNER_RECT_WIDTH, frame.right, frame.bottom, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
//绘制扫描线
|
||||||
|
private void drawLaserScanner(Canvas canvas, Rect frame) {
|
||||||
|
paint.setColor(laserColor);
|
||||||
|
//扫描线闪烁效果
|
||||||
|
// paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
|
||||||
|
// scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
|
||||||
|
// int middle = frame.height() / 2 + frame.top;
|
||||||
|
// canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
|
||||||
|
//线性渐变
|
||||||
|
LinearGradient linearGradient = new LinearGradient(
|
||||||
|
frame.left, scannerStart,
|
||||||
|
frame.left, scannerStart + SCANNER_LINE_HEIGHT,
|
||||||
|
shadeColor(laserColor),
|
||||||
|
laserColor,
|
||||||
|
Shader.TileMode.MIRROR);
|
||||||
|
|
||||||
|
RadialGradient radialGradient = new RadialGradient(
|
||||||
|
(float)(frame.left + frame.width() / 2),
|
||||||
|
(float)(scannerStart + SCANNER_LINE_HEIGHT / 2),
|
||||||
|
360f,
|
||||||
|
laserColor,
|
||||||
|
shadeColor(laserColor),
|
||||||
|
Shader.TileMode.MIRROR);
|
||||||
|
|
||||||
|
SweepGradient sweepGradient = new SweepGradient(
|
||||||
|
(float)(frame.left + frame.width() / 2),
|
||||||
|
(float)(scannerStart + SCANNER_LINE_HEIGHT),
|
||||||
|
shadeColor(laserColor),
|
||||||
|
laserColor);
|
||||||
|
|
||||||
|
ComposeShader composeShader = new ComposeShader(radialGradient, linearGradient, PorterDuff.Mode.ADD);
|
||||||
|
|
||||||
|
paint.setShader(radialGradient);
|
||||||
|
if(scannerStart <= scannerEnd) {
|
||||||
|
//矩形
|
||||||
|
// canvas.drawRect(frame.left, scannerStart, frame.right, scannerStart + SCANNER_LINE_HEIGHT, paint);
|
||||||
|
//椭圆
|
||||||
|
RectF rectF = new RectF(frame.left + 2 * SCANNER_LINE_HEIGHT, scannerStart, frame.right - 2 * SCANNER_LINE_HEIGHT, scannerStart + SCANNER_LINE_HEIGHT);
|
||||||
|
canvas.drawOval(rectF, paint);
|
||||||
|
scannerStart += SCANNER_LINE_MOVE_DISTANCE;
|
||||||
|
} else {
|
||||||
|
scannerStart = frame.top;
|
||||||
|
}
|
||||||
|
paint.setShader(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理颜色模糊
|
||||||
|
public int shadeColor(int color) {
|
||||||
|
String hax = Integer.toHexString(color);
|
||||||
|
String result = "20"+hax.substring(2);
|
||||||
|
return Integer.valueOf(result, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绘制扫描区边框 Draw a two pixel solid black border inside the framing rect
|
||||||
|
private void drawFrame(Canvas canvas, Rect frame) {
|
||||||
|
paint.setColor(frameColor);
|
||||||
|
canvas.drawRect(frame.left, frame.top, frame.right + 1, frame.top + 2, paint);
|
||||||
|
canvas.drawRect(frame.left, frame.top + 2, frame.left + 2, frame.bottom - 1, paint);
|
||||||
|
canvas.drawRect(frame.right - 1, frame.top, frame.right + 1, frame.bottom - 1, paint);
|
||||||
|
canvas.drawRect(frame.left, frame.bottom - 1, frame.right + 1, frame.bottom + 1, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绘制模糊区域 Draw the exterior (i.e. outside the framing rect) darkened
|
||||||
|
private void drawExterior(Canvas canvas, Rect frame, int width, int height) {
|
||||||
|
paint.setColor(resultBitmap != null ? resultColor : maskColor);
|
||||||
|
canvas.drawRect(0, 0, width, frame.top, paint);
|
||||||
|
canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
|
||||||
|
canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint);
|
||||||
|
canvas.drawRect(0, frame.bottom + 1, width, height, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawViewfinder() {
|
||||||
|
resultBitmap = null;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a bitmap with the result points highlighted instead of the live scanning display.
|
||||||
|
*
|
||||||
|
* @param barcode An image of the decoded barcode.
|
||||||
|
*/
|
||||||
|
public void drawResultBitmap(Bitmap barcode) {
|
||||||
|
resultBitmap = barcode;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPossibleResultPoint(ResultPoint point) {
|
||||||
|
possibleResultPoints.add(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package edu.hzuapps.androidlabs;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.Programs;
|
||||||
|
|
||||||
|
|
||||||
|
public class CollectFragment extends Fragment {
|
||||||
|
|
||||||
|
ListView listView;
|
||||||
|
View rootView;
|
||||||
|
List<Programs> dataList;
|
||||||
|
ArrayList<String> tagList;
|
||||||
|
|
||||||
|
public CollectFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CollectFragment newInstances(List<Programs> list, ArrayList<String> tag){
|
||||||
|
CollectFragment collectFragment = new CollectFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableArrayList("data", (ArrayList<? extends Parcelable>) list);
|
||||||
|
bundle.putStringArrayList("tag",tag);;
|
||||||
|
collectFragment.setArguments(bundle);
|
||||||
|
return collectFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if(getArguments()!=null){
|
||||||
|
dataList = getArguments().getParcelableArrayList("data");
|
||||||
|
tagList = getArguments().getStringArrayList("tag");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
if(rootView == null){
|
||||||
|
rootView = inflater.inflate(R.layout.fragment_collect, container, false);
|
||||||
|
}
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
initview();
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initview() {
|
||||||
|
listView = rootView.findViewById(R.id.lv_home);
|
||||||
|
listView.setAdapter(new MyBaseAdapter(dataList,tagList,this.getContext()));
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
String str = dataList.get(position).getAddr();
|
||||||
|
ClipboardManager cm;
|
||||||
|
ClipData mClipData;
|
||||||
|
//获取剪贴板管理器:
|
||||||
|
cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
// 创建普通字符型ClipData
|
||||||
|
mClipData = ClipData.newPlainText("Label", str);
|
||||||
|
// 将ClipData内容放到系统剪贴板里。
|
||||||
|
cm.setPrimaryClip(mClipData);
|
||||||
|
Toast.makeText(getContext(), "视频地址已复制到剪切板",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.GestureDetector;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.MediaController;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.until.ToolUtils;
|
||||||
|
|
||||||
|
import static android.content.Context.WINDOW_SERVICE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link HomeFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class HomeFragment extends Fragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
View rootView;
|
||||||
|
protected Button play;
|
||||||
|
protected VideoView videoView;
|
||||||
|
protected EditText edittext;
|
||||||
|
protected Button newplayer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public HomeFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static HomeFragment newInstance() {
|
||||||
|
HomeFragment fragment = new HomeFragment();
|
||||||
|
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
if(rootView == null){
|
||||||
|
rootView = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
|
}
|
||||||
|
edittext = rootView.findViewById(R.id.et_home);
|
||||||
|
play = rootView.findViewById(R.id.bt_play);
|
||||||
|
videoView = rootView.findViewById(R.id.vv_home);
|
||||||
|
videoView.setMediaController(new MediaController(rootView.getContext()));
|
||||||
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
|
play.setOnClickListener(this);
|
||||||
|
newplayer = rootView.findViewById(R.id.newplayer);
|
||||||
|
newplayer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(getContext(),MovieActivity.class);
|
||||||
|
intent.setData(Uri.parse(edittext.getText().toString()));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(videoView!=null && videoView.isPlaying()){
|
||||||
|
videoView.stopPlayback();
|
||||||
|
}
|
||||||
|
videoView.setVideoURI(Uri.parse(edittext.getText().toString()));
|
||||||
|
videoView.setVisibility(View.VISIBLE);
|
||||||
|
videoView.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.MediaController;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
|
||||||
|
public class MovieActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
VideoView videoView ;
|
||||||
|
EditText editText;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_movie);
|
||||||
|
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.hide(); //隐藏标题栏
|
||||||
|
}
|
||||||
|
|
||||||
|
videoView = findViewById(R.id.videoview);
|
||||||
|
editText = findViewById(R.id.et_home);
|
||||||
|
videoView.setMediaController(new MediaController(this));
|
||||||
|
videoView.setVideoURI(getIntent().getData());
|
||||||
|
videoView.start();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
videoView = findViewById(R.id.videoview);
|
||||||
|
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,dip2px(this,235f));
|
||||||
|
params.addRule(RelativeLayout.CENTER_IN_PARENT);
|
||||||
|
videoView.setLayoutParams(params);
|
||||||
|
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
videoView.setLayoutParams(new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
||||||
|
*/
|
||||||
|
public static int dip2px(Context context, float dpValue) {
|
||||||
|
final float scale = context.getResources().getDisplayMetrics().density;
|
||||||
|
return (int) (dpValue * scale + 0.5f);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.Programs;
|
||||||
|
|
||||||
|
public class MyBaseAdapter extends BaseAdapter {
|
||||||
|
|
||||||
|
private List<Programs> data;
|
||||||
|
private List<String> datatag;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public MyBaseAdapter(List<Programs> data,List<String> datatag, Context context) {
|
||||||
|
this.data = data;
|
||||||
|
this.datatag = datatag;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return data.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
if (convertView == null) {
|
||||||
|
if(datatag.contains(data.get(position).getName())){
|
||||||
|
convertView = LayoutInflater.from(context).inflate(R.layout.list_item_tag, parent, false);
|
||||||
|
}else{
|
||||||
|
convertView = LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
TextView textview = convertView.findViewById(R.id.tv_item);
|
||||||
|
textview.setText(data.get(position).getName());
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MyFragmentAdapter extends FragmentStateAdapter {
|
||||||
|
|
||||||
|
List<Fragment> list = new ArrayList<>();
|
||||||
|
|
||||||
|
public MyFragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle,List<Fragment> flist) {
|
||||||
|
super(fragmentManager, lifecycle);
|
||||||
|
list = flist;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment createFragment(int position) {
|
||||||
|
return list.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return list.size();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
public class MyVideoView extends VideoView {
|
||||||
|
public MyVideoView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyVideoView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
int width = getDefaultSize(0, widthMeasureSpec);
|
||||||
|
int height = getDefaultSize(0, heightMeasureSpec);
|
||||||
|
setMeasuredDimension(width,height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
|
||||||
|
public class SelectActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_select);
|
||||||
|
|
||||||
|
Button back = findViewById(R.id.btn_back);
|
||||||
|
back.setOnClickListener(this);
|
||||||
|
Button search = findViewById(R.id.btn_search);
|
||||||
|
search.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()){
|
||||||
|
case R.id.btn_search:
|
||||||
|
break;
|
||||||
|
case R.id.btn_back:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link UserFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class UserFragment extends Fragment {
|
||||||
|
|
||||||
|
View rootview;
|
||||||
|
|
||||||
|
|
||||||
|
public UserFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static UserFragment newInstance() {
|
||||||
|
UserFragment fragment = new UserFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
if(rootview == null){
|
||||||
|
rootview = inflater.inflate(R.layout.fragment_user, container, false);
|
||||||
|
}
|
||||||
|
ImageView imageView = rootview.findViewById(R.id.imageView);
|
||||||
|
Glide.with(this)
|
||||||
|
.load(R.drawable.myphoto)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCorners(180)))
|
||||||
|
.into(imageView);
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return rootview;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,300 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.MediaController;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import com.dommy.qrcode.util.Constant;
|
||||||
|
import com.geogle.zxing.activity.CaptureActivity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.R;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.Programs;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.manager.DBEngine;
|
||||||
|
|
||||||
|
public class WatchTVActivity extends AppCompatActivity implements View.OnClickListener{
|
||||||
|
|
||||||
|
private static final String TAG = "zhu";
|
||||||
|
final WatchTVActivity thisActivity = this;
|
||||||
|
private List<Programs> data = null;
|
||||||
|
private ArrayList<String> datatag = null;
|
||||||
|
private Context thiscontext = this;
|
||||||
|
|
||||||
|
protected ViewPager2 viewPager;
|
||||||
|
protected LinearLayout lhome,lstar,lacc;
|
||||||
|
protected ImageView ivhome,ivstar,ivacc,ivcurr;
|
||||||
|
protected Button btnSearch,btnScanner,btnMore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_watch_t_v);
|
||||||
|
|
||||||
|
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||||
|
100);
|
||||||
|
|
||||||
|
DBEngine db = new DBEngine(thiscontext);
|
||||||
|
|
||||||
|
// dataInit();
|
||||||
|
// data = dataQuery();
|
||||||
|
dataInit();
|
||||||
|
initPage();
|
||||||
|
initMoudle();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Programs> dataQuery() {
|
||||||
|
List<Programs> list = new ArrayList<Programs>();
|
||||||
|
// Resources resources = getResources();
|
||||||
|
// String[] name = resources.getStringArray(R.array.name);
|
||||||
|
// String[] url = resources.getStringArray(R.array.addr);
|
||||||
|
// for (int i = 0; i < name.length; i++) {
|
||||||
|
// Programs programs = new Programs();
|
||||||
|
// programs.setName(name[i]);
|
||||||
|
// programs.setAddr(url[i]);
|
||||||
|
// programs.setId(i);
|
||||||
|
// list.add(programs);
|
||||||
|
// }
|
||||||
|
// DBEngine db = new DBEngine(this);
|
||||||
|
// List<Programs> list = db.queryAllPrograms();
|
||||||
|
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataInit() {
|
||||||
|
|
||||||
|
data = new ArrayList<>();
|
||||||
|
datatag = new ArrayList<String>();
|
||||||
|
Resources resources = getResources();
|
||||||
|
String[] url = resources.getStringArray(R.array.addr);
|
||||||
|
datatag.add("新闻");
|
||||||
|
Programs p = new Programs();
|
||||||
|
p.setName("新闻");
|
||||||
|
data.add(p);
|
||||||
|
int index = 0;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
Programs programs = new Programs();
|
||||||
|
programs.setName("新闻"+(i+1));
|
||||||
|
programs.setAddr(url[index]);
|
||||||
|
programs.setId(index++);
|
||||||
|
data.add(programs);
|
||||||
|
}
|
||||||
|
|
||||||
|
datatag.add("娱乐");
|
||||||
|
p = new Programs();
|
||||||
|
p.setName("娱乐");
|
||||||
|
data.add(p);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
Programs programs = new Programs();
|
||||||
|
programs.setName("娱乐"+(i+1));
|
||||||
|
programs.setAddr(url[index]);
|
||||||
|
programs.setId(index++);
|
||||||
|
data.add(programs);
|
||||||
|
}
|
||||||
|
datatag.add("自然");
|
||||||
|
p = new Programs();
|
||||||
|
p.setName("自然");
|
||||||
|
data.add(p);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
Programs programs = new Programs();
|
||||||
|
programs.setName("自然"+(i+1));
|
||||||
|
programs.setAddr(url[index]);
|
||||||
|
programs.setId(index++);
|
||||||
|
data.add(programs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPage(){
|
||||||
|
viewPager = findViewById(R.id.vp_mid);
|
||||||
|
ArrayList<Fragment> fragments= new ArrayList<>();
|
||||||
|
fragments.add(HomeFragment.newInstance());
|
||||||
|
fragments.add(CollectFragment.newInstances(data,datatag));
|
||||||
|
fragments.add(UserFragment.newInstance());
|
||||||
|
viewPager.setAdapter(new MyFragmentAdapter(getSupportFragmentManager(),getLifecycle(),fragments));
|
||||||
|
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
super.onPageSelected(position);
|
||||||
|
changTab(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
super.onPageScrollStateChanged(state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void initMoudle(){
|
||||||
|
lhome = findViewById(R.id.part_home);
|
||||||
|
lstar = findViewById(R.id.part_collect);
|
||||||
|
lacc = findViewById(R.id.ll_friend);
|
||||||
|
ivhome = findViewById(R.id.iv_home);
|
||||||
|
ivstar = findViewById(R.id.iv_collect);
|
||||||
|
ivacc = findViewById(R.id.iv_user);
|
||||||
|
btnSearch = findViewById(R.id.btn_search);
|
||||||
|
btnScanner = findViewById(R.id.btn_scanner);
|
||||||
|
btnMore = findViewById(R.id.btn_more);
|
||||||
|
|
||||||
|
lhome.setOnClickListener(this);
|
||||||
|
lstar.setOnClickListener(this);
|
||||||
|
lacc.setOnClickListener(this);
|
||||||
|
btnSearch.setOnClickListener(this);
|
||||||
|
btnScanner.setOnClickListener(this);
|
||||||
|
btnMore.setOnClickListener(this);
|
||||||
|
|
||||||
|
ivcurr = ivhome;
|
||||||
|
ivhome.setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changTab(int position) {
|
||||||
|
ivcurr.setSelected(false);
|
||||||
|
switch (position){
|
||||||
|
case R.id.part_home:
|
||||||
|
viewPager.setCurrentItem(0);
|
||||||
|
case 0:
|
||||||
|
ivhome.setSelected(true);
|
||||||
|
ivcurr = ivhome;
|
||||||
|
break;
|
||||||
|
case R.id.part_collect:
|
||||||
|
viewPager.setCurrentItem(1);
|
||||||
|
case 1:
|
||||||
|
ivstar.setSelected(true);
|
||||||
|
ivcurr = ivstar;
|
||||||
|
break;
|
||||||
|
case R.id.ll_friend:
|
||||||
|
case R.id.btn_more:
|
||||||
|
viewPager.setCurrentItem(2);
|
||||||
|
case 2:
|
||||||
|
ivacc.setSelected(true);
|
||||||
|
ivcurr = ivacc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()){
|
||||||
|
case R.id.btn_more:
|
||||||
|
case R.id.part_home:
|
||||||
|
case R.id.part_collect:
|
||||||
|
case R.id.ll_friend:
|
||||||
|
changTab(v.getId());
|
||||||
|
break;
|
||||||
|
case R.id.btn_search:
|
||||||
|
Intent intent = new Intent(thisActivity, SelectActivity.class);
|
||||||
|
thisActivity.startActivity(intent);
|
||||||
|
break;
|
||||||
|
case R.id.btn_scanner:
|
||||||
|
startQrCode();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始扫码
|
||||||
|
private void startQrCode() {
|
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
|
||||||
|
Toast.makeText(WatchTVActivity.this, "请至权限中心打开本应用的相机访问权限", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
// 申请权限
|
||||||
|
ActivityCompat.requestPermissions(WatchTVActivity.this, new String[]{Manifest.permission.CAMERA}, Constant.REQ_PERM_CAMERA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 二维码扫码
|
||||||
|
Intent intent = new Intent(WatchTVActivity.this, CaptureActivity.class);
|
||||||
|
startActivityForResult(intent, Constant.REQ_QR_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
String result = "";
|
||||||
|
//扫描结果回调
|
||||||
|
if (requestCode == Constant.REQ_QR_CODE && resultCode == RESULT_OK) {
|
||||||
|
if (data != null) {
|
||||||
|
Bundle bundle = data.getExtras();
|
||||||
|
if (bundle == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = bundle.getString(Constant.INTENT_EXTRA_KEY_QR_SCAN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setData(Uri.parse(result)); //splitflowurl为分流地址
|
||||||
|
if (!hasPreferredApplication(this,intent)){
|
||||||
|
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
|
||||||
|
}
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPreferredApplication(Context context, Intent intent) {
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
return !"android".equals(info.activityInfo.packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
switch (requestCode) {
|
||||||
|
case Constant.REQ_PERM_CAMERA:
|
||||||
|
// 摄像头权限申请
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// 获得授权
|
||||||
|
startQrCode();
|
||||||
|
} else {
|
||||||
|
// 被禁止授权
|
||||||
|
Toast.makeText(WatchTVActivity.this, "请至权限中心打开本应用的相机访问权限", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv.room;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Programs implements Parcelable {
|
||||||
|
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private String addr;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public Programs() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddr() {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddr(String addr) {
|
||||||
|
this.addr = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Programs(int id, String name, String addr) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.addr = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Programs{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", addr='" + addr + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeInt(id);
|
||||||
|
dest.writeString(name);
|
||||||
|
dest.writeString(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<Programs> CREATOR = new Creator(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Programs createFromParcel(Parcel source) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
// 必须按成员变量声明的顺序读取数据,不然会出现获取数据出错
|
||||||
|
Programs p = new Programs();
|
||||||
|
p.setId(source.readInt());
|
||||||
|
p.setName(source.readString());
|
||||||
|
p.setAddr(source.readString());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Programs[] newArray(int size) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new Programs[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv.room;
|
||||||
|
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface ProgramsDao {
|
||||||
|
@Insert
|
||||||
|
void insertPrograms(Programs... programs);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM programs")
|
||||||
|
List<Programs> queryAllPrograms();
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv.room;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.room.Database;
|
||||||
|
import androidx.room.Room;
|
||||||
|
import androidx.room.RoomDatabase;
|
||||||
|
|
||||||
|
@Database(entities = {Programs.class},version = 1,exportSchema = false)
|
||||||
|
public abstract class ProgramsDatabase extends RoomDatabase {
|
||||||
|
|
||||||
|
public abstract ProgramsDao getProgramsDao();
|
||||||
|
|
||||||
|
private static ProgramsDatabase INSTANCE;
|
||||||
|
public static synchronized ProgramsDatabase getINSTANCE(Context context){
|
||||||
|
if(INSTANCE == null){
|
||||||
|
INSTANCE = Room.databaseBuilder
|
||||||
|
(context.getApplicationContext(),ProgramsDatabase.class,"programe_database")
|
||||||
|
.allowMainThreadQueries()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv.room.manager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.Programs;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.ProgramsDao;
|
||||||
|
import edu.hzuapps.androidlabs.watchtv.room.ProgramsDatabase;
|
||||||
|
|
||||||
|
public class DBEngine{
|
||||||
|
|
||||||
|
private ProgramsDao programsDao;
|
||||||
|
private List<Programs> list;
|
||||||
|
private String teststr;
|
||||||
|
|
||||||
|
|
||||||
|
public DBEngine(Context context) {
|
||||||
|
ProgramsDatabase programsDatabase = ProgramsDatabase.getINSTANCE(context);
|
||||||
|
programsDao = programsDatabase.getProgramsDao();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertPrograms(Programs... programs) {
|
||||||
|
programsDao.insertPrograms(programs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Programs> queryAllPrograms() {
|
||||||
|
List<Programs> list = programsDao.queryAllPrograms();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private static class InsertAsyncTask extends AsyncTask<Programs,Void,Void>{
|
||||||
|
//
|
||||||
|
// private ProgramsDao dao;
|
||||||
|
//
|
||||||
|
// public InsertAsyncTask(ProgramsDao dao) {
|
||||||
|
// this.dao = dao;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected Void doInBackground(Programs... programs) {
|
||||||
|
// dao.insertPrograms(programs);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package edu.hzuapps.androidlabs.watchtv.until;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
public class ToolUtils {
|
||||||
|
|
||||||
|
public static int dip2px(FragmentActivity context, float dpValue) {
|
||||||
|
final float scale = context.getResources().getDisplayMetrics().density;
|
||||||
|
return (int) (dpValue * scale + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 218 B |
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/ic_baseline_account_circle_24_actvite" android:state_selected="true"/>
|
||||||
|
<item android:drawable="@drawable/ic_baseline_account_circle_24" />
|
||||||
|
|
||||||
|
</selector>
|
After Width: | Height: | Size: 168 KiB |
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<shape
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FFFFFF"/>
|
||||||
|
<corners android:radius="5dp"/>
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="#58C8FB"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/ic_baseline_house_24_active" android:state_selected="true"/>
|
||||||
|
<item android:drawable="@drawable/ic_baseline_house_24"/>
|
||||||
|
</selector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlActivated">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.78,0 2.44,0.85 2.5,2.1h2.21c-0.07,-1.72 -1.12,-3.3 -3.21,-3.81V3h-3v2.16c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -2.06,0 -2.87,-0.92 -2.98,-2.1h-2.2c0.12,2.19 1.76,3.42 3.68,3.83V21h3v-2.15c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M4,10.5c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zM4,4.5c-0.83,0 -1.5,0.67 -1.5,1.5S3.17,7.5 4,7.5 5.5,6.83 5.5,6 4.83,4.5 4,4.5zM4,16.5c-0.83,0 -1.5,0.68 -1.5,1.5s0.68,1.5 1.5,1.5 1.5,-0.68 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zM7,19h14v-2L7,17v2zM7,13h14v-2L7,11v2zM7,5v2h14L21,5L7,5z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3zM10,10c0,-1.1 0.9,-2 2,-2s2,0.9 2,2H10z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlActivated">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3zM10,10c0,-1.1 0.9,-2 2,-2s2,0.9 2,2H10z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,6h-7.59l3.29,-3.29L16,2l-4,4 -4,-4 -0.71,0.71L10.59,6L3,6c-1.1,0 -2,0.89 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,8c0,-1.11 -0.9,-2 -2,-2zM21,20L3,20L3,8h18v12zM9,10v8l7,-4z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19.48,12.35c-1.57,-4.08 -7.16,-4.3 -5.81,-10.23c0.1,-0.44 -0.37,-0.78 -0.75,-0.55C9.29,3.71 6.68,8 8.87,13.62c0.18,0.46 -0.36,0.89 -0.75,0.59c-1.81,-1.37 -2,-3.34 -1.84,-4.75c0.06,-0.52 -0.62,-0.77 -0.91,-0.34C4.69,10.16 4,11.84 4,14.37c0.38,5.6 5.11,7.32 6.81,7.54c2.43,0.31 5.06,-0.14 6.95,-1.87C19.84,18.11 20.6,15.03 19.48,12.35zM10.2,17.38c1.44,-0.35 2.18,-1.39 2.38,-2.31c0.33,-1.43 -0.96,-2.83 -0.09,-5.09c0.33,1.87 3.27,3.04 3.27,5.08C15.84,17.59 13.1,19.76 10.2,17.38z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M9.5,6.5v3h-3v-3H9.5M11,5H5v6h6V5L11,5zM9.5,14.5v3h-3v-3H9.5M11,13H5v6h6V13L11,13zM17.5,6.5v3h-3v-3H17.5M19,5h-6v6h6V5L19,5zM13,13h1.5v1.5H13V13zM14.5,14.5H16V16h-1.5V14.5zM16,13h1.5v1.5H16V13zM13,16h1.5v1.5H13V16zM14.5,17.5H16V19h-1.5V17.5zM16,16h1.5v1.5H16V16zM17.5,14.5H19V16h-1.5V14.5zM17.5,17.5H19V19h-1.5V17.5zM22,7h-2V4h-3V2h5V7zM22,22v-5h-2v3h-3v2H22zM2,22h5v-2H4v-3H2V22zM2,2v5h2V4h3V2H2z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlActivated">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,10.12h-6.78l2.74,-2.82c-2.73,-2.7 -7.15,-2.8 -9.88,-0.1c-2.73,2.71 -2.73,7.08 0,9.79s7.15,2.71 9.88,0C18.32,15.65 19,14.08 19,12.1h2c0,1.98 -0.88,4.55 -2.64,6.29c-3.51,3.48 -9.21,3.48 -12.72,0c-3.5,-3.47 -3.53,-9.11 -0.02,-12.58s9.14,-3.47 12.65,0L21,3V10.12zM12.5,8v4.25l3.5,2.08l-0.72,1.21L11,13V8H12.5z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</selector>
|
After Width: | Height: | Size: 48 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="10dp"/>
|
||||||
|
<stroke
|
||||||
|
android:width="3dp"
|
||||||
|
android:color="#95a1aa"/>
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="5dp"
|
||||||
|
android:left="10dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:top="5dp"/>
|
||||||
|
<corners android:radius="10dp"/>
|
||||||
|
</shape>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/ic_baseline_star_24_actvite" android:state_selected="true"/>
|
||||||
|
<item android:drawable="@drawable/ic_baseline_star_24"/>
|
||||||
|
</selector>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</selector>
|
@ -0,0 +1,83 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:background="#ECECEC">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/part_home"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_home"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/house_select" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_home"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:text="首页"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/part_collect"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_collect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/star_select" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_collect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:text="收藏"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_friend"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_user"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/account_select" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_user"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:text="我的"
|
||||||
|
android:textColor="#808080"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Hello World!"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/vp_mid"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
<!-- <ListView-->
|
||||||
|
<!-- android:id="@+id/lv_home"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="match_parent"/>-->
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:context=".watchtv.MovieActivity">
|
||||||
|
|
||||||
|
<VideoView
|
||||||
|
android:id="@+id/videoview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp" >
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/reminder" />
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/dates"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:layout_below="@id/name"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_toLeftOf="@+id/times" />
|
||||||
|
<Spinner
|
||||||
|
android:id="@id/times"
|
||||||
|
android:layout_width="96dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:layout_below="@id/name"
|
||||||
|
android:layout_alignParentRight="true" />
|
||||||
|
<Button
|
||||||
|
android:layout_width="96dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/times"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="@string/done" />
|
||||||
|
</RelativeLayout>
|
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/toolbar_scanner" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<SurfaceView
|
||||||
|
android:id="@+id/scanner_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
|
<com.geogle.zxing.view.ViewfinderView
|
||||||
|
android:id="@+id/viewfinder_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:corner_color="@color/corner_color"
|
||||||
|
app:frame_color="@color/viewfinder_frame"
|
||||||
|
app:label_text="二维码/条形码扫描"
|
||||||
|
app:label_text_color="@color/colorAccent"
|
||||||
|
app:laser_color="@color/laser_color"
|
||||||
|
app:mask_color="@color/viewfinder_mask"
|
||||||
|
app:result_color="@color/result_view"
|
||||||
|
app:result_point_color="@color/result_point_color" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/btn_flash"
|
||||||
|
android:layout_width="40dip"
|
||||||
|
android:layout_height="40dip"
|
||||||
|
android:padding="6dip"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:layout_marginBottom="30dip"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/flash_off" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginTop="5dp">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_back"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/ic_baseline_chevron_left_24"/>
|
||||||
|
<EditText
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableLeft="@drawable/ic_baseline_search_24"
|
||||||
|
android:hint="在此输入搜索"
|
||||||
|
android:textColorHint="#95a1aa"
|
||||||
|
android:background="@drawable/search_shape"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_search"
|
||||||
|
android:layout_width="70dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#00ffffff"
|
||||||
|
android:text="搜索"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:fontFamily="黑体"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".soft1914080902251.Soft1914080902251Activity">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/open_activity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="打开一个新Activity"
|
||||||
|
tools:layout_editor_absoluteX="142dp"
|
||||||
|
tools:layout_editor_absoluteY="149dp" />
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:navigationIcon="@drawable/ic_baseline_live_tv_24"
|
||||||
|
app:title="网络电视">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_more"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:background="@drawable/ic_baseline_more_horiz_24" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_scanner"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:background="@drawable/ic_baseline_qr_code_scanner_24" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_search"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
|
||||||
|
android:background="@drawable/ic_baseline_search_24" />
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="edu.hzuapps.androidlabs.soft1914080902251.ViewByJavaActivity">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_show"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/show_text"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".watchtv.WatchTVActivity">
|
||||||
|
|
||||||
|
<include layout="@layout/activity_top" />
|
||||||
|
<include layout="@layout/activity_mid"/>
|
||||||
|
<include layout="@layout/activity_bottom" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".watchtv.CollectFragment">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/lv_home"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".watchtv.HomeFragment"
|
||||||
|
>
|
||||||
|
|
||||||
|
<!-- TODO: Update blank fragment layout -->
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_home"
|
||||||
|
android:layout_width="350sp"
|
||||||
|
android:layout_height="200sp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="left|top"
|
||||||
|
android:background="@drawable/edit_background"
|
||||||
|
android:hint="输入视频播放路径"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="350sp"
|
||||||
|
android:layout_height="50sp"
|
||||||
|
android:layout_marginTop="10sp"
|
||||||
|
android:layout_gravity="center_horizontal">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_collect"
|
||||||
|
android:layout_width="100sp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="收藏"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bt_play"
|
||||||
|
android:layout_width="100sp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="预览"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="350sp"
|
||||||
|
android:layout_height="200sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="20sp"
|
||||||
|
android:layout_gravity="center_horizontal">
|
||||||
|
<VideoView
|
||||||
|
android:id="@+id/vv_home"
|
||||||
|
android:layout_width="350sp"
|
||||||
|
android:layout_height="200sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/newplayer"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="播放"/>
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_item"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="30sp"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/gray"
|
||||||
|
android:paddingLeft="10dip">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_item"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="30dip"
|
||||||
|
android:textColor="#444444"
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:contentInsetStart="0dip">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/btn_back"
|
||||||
|
android:layout_width="40dip"
|
||||||
|
android:layout_height="40dip"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:padding="10dip"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/btn_back" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:text="扫描二维码"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_album"
|
||||||
|
android:layout_width="40dip"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginRight="10dip"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:text="相册"
|
||||||
|
android:textColor="@android:color/white" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
Binary file not shown.
@ -0,0 +1,16 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.AndroidLabs" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/purple_200</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/black</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string-array name="name">
|
||||||
|
<item>视频1</item>
|
||||||
|
<item>视频2</item>
|
||||||
|
<item>视频3</item>
|
||||||
|
<item>视频4</item>
|
||||||
|
<item>视频5</item>
|
||||||
|
<item>视频6</item>
|
||||||
|
<item>视频7</item>
|
||||||
|
<item>视频8</item>
|
||||||
|
<item>视频9</item>
|
||||||
|
<item>视频10</item>
|
||||||
|
<item>视频11</item>
|
||||||
|
<item>视频12</item>
|
||||||
|
<item>视频13</item>
|
||||||
|
<item>视频14</item>
|
||||||
|
<item>视频15</item>
|
||||||
|
<item>视频16</item>
|
||||||
|
<item>视频17</item>
|
||||||
|
<item>视频18</item>
|
||||||
|
<item>视频19</item>
|
||||||
|
<item>视频20</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="addr">
|
||||||
|
<item>https://v-cdn.zjol.com.cn/280443.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276982.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276984.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276985.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276986.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276987.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276988.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276989.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276990.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276991.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276992.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276993.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276994.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276996.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/276998.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/277000.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/277001.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/277002.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/277003.mp4</item>
|
||||||
|
<item>https://v-cdn.zjol.com.cn/277004.mp4</item>
|
||||||
|
|
||||||
|
|
||||||
|
</string-array>
|
||||||
|
</resources>
|
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--corner_color 边角颜色,
|
||||||
|
scanner_color 扫描线颜色
|
||||||
|
possible_result_color 扫描点颜色
|
||||||
|
frame_color 扫描框边线颜色
|
||||||
|
mask_color 模糊区域颜色
|
||||||
|
label_text 框上方提示
|
||||||
|
-->
|
||||||
|
<declare-styleable name="ViewfinderView">
|
||||||
|
<attr name="corner_color" format="color"/>
|
||||||
|
<attr name="laser_color" format="color"/>
|
||||||
|
<attr name="frame_color" format="color" />
|
||||||
|
<attr name="mask_color" format="color" />
|
||||||
|
<attr name="result_point_color" format="color"/>
|
||||||
|
<attr name="result_color" format="color" />
|
||||||
|
<attr name="label_text_color" format="color"/>
|
||||||
|
<attr name="label_text" format="string"/>
|
||||||
|
<attr name="label_text_size" format="float"/>
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
</resources>
|
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="gray">#ededed</color>
|
||||||
|
|
||||||
|
<!-- QRCode scanner color begin -->
|
||||||
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
<color name="viewfinder_mask">#60000000</color>
|
||||||
|
<color name="result_view">#B0000000</color>
|
||||||
|
<color name="viewfinder_frame">#90FFFFFF</color>
|
||||||
|
<color name="result_point_color">#C0FFFF00</color>
|
||||||
|
<color name="laser_color">#0F0</color>
|
||||||
|
<color name="corner_color">#00FF00</color>
|
||||||
|
<!-- QRCode scanner color end -->
|
||||||
|
</resources>
|
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2008 ZXing authors
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<!-- Messages IDs -->
|
||||||
|
<item type="id" name="auto_focus"/>
|
||||||
|
<item type="id" name="decode"/>
|
||||||
|
<item type="id" name="decode_failed"/>
|
||||||
|
<item type="id" name="decode_succeeded"/>
|
||||||
|
<item type="id" name="encode_failed"/>
|
||||||
|
<item type="id" name="encode_succeeded"/>
|
||||||
|
<item type="id" name="launch_product_query"/>
|
||||||
|
<item type="id" name="quit"/>
|
||||||
|
<item type="id" name="restart_preview"/>
|
||||||
|
<item type="id" name="return_scan_result"/>
|
||||||
|
<item type="id" name="search_book_contents_failed"/>
|
||||||
|
<item type="id" name="search_book_contents_succeeded"/>
|
||||||
|
</resources>
|
@ -0,0 +1,10 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">AndroidLabs</string>
|
||||||
|
<string name="show_text">is you</string>
|
||||||
|
<string name="text_line">123</string>
|
||||||
|
<string name="reminder">reminder</string>
|
||||||
|
<string name="done">done</string>
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
<string name="buffering">1</string>
|
||||||
|
</resources>
|
@ -0,0 +1,16 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.AndroidLabs" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/purple_500</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/white</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
Loading…
Reference in new issue