Compare commits
2 Commits
1fd760e80a
...
c77196ce0d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c77196ce0d | ||
|
|
5e8ea12f69 |
@@ -156,10 +156,10 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
|
||||||
|
|
||||||
//zxing 依赖 二维码,扫描等使用
|
//扫码:ZXingLite(CameraX + zxing-core),替代已停止维护的 MNZXingCode
|
||||||
implementation 'com.google.zxing:core:3.4.1'
|
implementation 'com.github.jenly1314:zxing-lite:3.5.0'
|
||||||
// implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
//相册选择:AndroidX Photo Picker,无需存储权限
|
||||||
implementation 'com.github.maning0303:MNZXingCode:V2.1.9'
|
implementation 'androidx.activity:activity:1.9.3'
|
||||||
//该库专门用于在 ImageView 中处理 GIF 动画。
|
//该库专门用于在 ImageView 中处理 GIF 动画。
|
||||||
// implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
|
// implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
|
||||||
//下载框架
|
//下载框架
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<!-- 扫码使用相机,但相机不是必需硬件,保证无相机设备也能安装并手动输入编码 -->
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.camera"
|
||||||
|
android:required="false" />
|
||||||
|
<uses-feature
|
||||||
|
android:name="android.hardware.camera.any"
|
||||||
|
android:required="false" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.READ_MEDIA_IMAGES"/>
|
android:name="android.permission.READ_MEDIA_IMAGES"/>
|
||||||
@@ -151,6 +158,16 @@
|
|||||||
android:name=".product.ProductInboundActivity"
|
android:name=".product.ProductInboundActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
<activity
|
||||||
|
android:name=".product.ProductScanActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:theme="@style/ProductScanTheme" />
|
||||||
|
<activity
|
||||||
|
android:name=".product.DeviceManageActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".login.LoginActivity"
|
android:name=".login.LoginActivity"
|
||||||
android:theme="@style/AppTheme.FullScreen"
|
android:theme="@style/AppTheme.FullScreen"
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import androidx.viewpager.widget.ViewPager;
|
|||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.google.zxing.client.android.utils.ZXingUtils;
|
import com.king.zxing.util.CodeUtils;
|
||||||
import com.ckkj.griddlebiz.AppConfig;
|
import com.ckkj.griddlebiz.AppConfig;
|
||||||
import com.ckkj.griddlebiz.R;
|
import com.ckkj.griddlebiz.R;
|
||||||
import com.ckkj.griddlebiz.guide.GuideActivity;
|
import com.ckkj.griddlebiz.guide.GuideActivity;
|
||||||
@@ -181,8 +181,10 @@ public class ShareQrcodeDialog {
|
|||||||
*/
|
*/
|
||||||
private void authUrlToQrcode(String data) {
|
private void authUrlToQrcode(String data) {
|
||||||
try {
|
try {
|
||||||
Bitmap qrImage = ZXingUtils.createQRCodeImage(AppConfig.USER_SHARE_URL + data);
|
Bitmap qrImage = CodeUtils.createQRCode(AppConfig.USER_SHARE_URL + data, 600);
|
||||||
imgQrcode.setImageBitmap(qrImage);
|
if (qrImage != null) {
|
||||||
|
imgQrcode.setImageBitmap(qrImage);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.ckkj.griddlebiz.base.BaseFragment;
|
|||||||
import com.ckkj.griddlebiz.base.IPresenter;
|
import com.ckkj.griddlebiz.base.IPresenter;
|
||||||
import com.ckkj.griddlebiz.databinding.HomeFragmentBinding;
|
import com.ckkj.griddlebiz.databinding.HomeFragmentBinding;
|
||||||
import com.ckkj.griddlebiz.network.BaseBean;
|
import com.ckkj.griddlebiz.network.BaseBean;
|
||||||
|
import com.ckkj.griddlebiz.product.DeviceManageActivity;
|
||||||
import com.ckkj.griddlebiz.product.ProductInboundActivity;
|
import com.ckkj.griddlebiz.product.ProductInboundActivity;
|
||||||
import com.ckkj.griddlebiz.utils.show.ToastUtil;
|
import com.ckkj.griddlebiz.utils.show.ToastUtil;
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ public class HomeFragment extends BaseFragment<HomeFragmentBinding, IPresenter>
|
|||||||
viewBinding.ivCompanyProfile.setOnClickListener(openUnavailable);
|
viewBinding.ivCompanyProfile.setOnClickListener(openUnavailable);
|
||||||
viewBinding.actionProductInbound.setOnClickListener(v ->
|
viewBinding.actionProductInbound.setOnClickListener(v ->
|
||||||
startActivity(new Intent(mContext, ProductInboundActivity.class)));
|
startActivity(new Intent(mContext, ProductInboundActivity.class)));
|
||||||
viewBinding.actionProductManagement.setOnClickListener(openUnavailable);
|
viewBinding.actionProductManagement.setOnClickListener(v ->
|
||||||
|
startActivity(new Intent(mContext, DeviceManageActivity.class)));
|
||||||
viewBinding.actionStatistics.setOnClickListener(openUnavailable);
|
viewBinding.actionStatistics.setOnClickListener(openUnavailable);
|
||||||
viewBinding.actionAfterSales.setOnClickListener(openUnavailable);
|
viewBinding.actionAfterSales.setOnClickListener(openUnavailable);
|
||||||
viewBinding.actionPickupVerification.setOnClickListener(openUnavailable);
|
viewBinding.actionPickupVerification.setOnClickListener(openUnavailable);
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package com.ckkj.griddlebiz.product;
|
||||||
|
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.ckkj.griddlebiz.R;
|
||||||
|
import com.ckkj.griddlebiz.base.BaseActivityNoP;
|
||||||
|
import com.ckkj.griddlebiz.databinding.DeviceManageLayoutBinding;
|
||||||
|
import com.ckkj.griddlebiz.network.BaseBean;
|
||||||
|
import com.ckkj.griddlebiz.utils.show.ToastUtil;
|
||||||
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备管理:全部设备与待激活两个 Tab。
|
||||||
|
* 页面数据目前使用设计稿示例,后续接入设备列表接口时替换。
|
||||||
|
*/
|
||||||
|
public class DeviceManageActivity extends BaseActivityNoP<DeviceManageLayoutBinding> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutResId(Bundle savedInstanceState) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initData(Bundle savedInstanceState) {
|
||||||
|
super.initData(savedInstanceState);
|
||||||
|
ImmersionBar.with(this)
|
||||||
|
.statusBarColor(R.color.white)
|
||||||
|
.statusBarDarkFont(true)
|
||||||
|
.keyboardEnable(true)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
viewBinding.ivBack.setOnClickListener(v -> finish());
|
||||||
|
viewBinding.tabAll.setOnClickListener(v -> selectTab(true));
|
||||||
|
viewBinding.tabPending.setOnClickListener(v -> selectTab(false));
|
||||||
|
viewBinding.chipAll.setSelected(true);
|
||||||
|
setupChipGroup(viewBinding.chipAll, viewBinding.chipOnline,
|
||||||
|
viewBinding.chipOffline, viewBinding.chipFault);
|
||||||
|
setupChipGroup(viewBinding.chipLast7Days, viewBinding.chipLast30Days,
|
||||||
|
viewBinding.chipCustom);
|
||||||
|
|
||||||
|
viewBinding.tvTotalDevices.setText(
|
||||||
|
getString(R.string.device_manage_total_devices, 24));
|
||||||
|
viewBinding.tvInStock.setText(getString(R.string.device_manage_in_stock, 3));
|
||||||
|
viewBinding.tvSold.setText(getString(R.string.device_manage_sold, 5));
|
||||||
|
|
||||||
|
viewBinding.ivSearch.setOnClickListener(v -> onSearch());
|
||||||
|
viewBinding.etSearch.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
|
onSearch();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
selectTab(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectTab(boolean allDevices) {
|
||||||
|
viewBinding.scrollAll.setVisibility(allDevices ? View.VISIBLE : View.GONE);
|
||||||
|
viewBinding.scrollPending.setVisibility(allDevices ? View.GONE : View.VISIBLE);
|
||||||
|
viewBinding.indicatorAll.setVisibility(allDevices ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
viewBinding.indicatorPending.setVisibility(allDevices ? View.INVISIBLE : View.VISIBLE);
|
||||||
|
|
||||||
|
viewBinding.tvTabAll.setTextColor(getColor(
|
||||||
|
allDevices ? R.color.device_manage_orange : R.color.device_manage_text_primary));
|
||||||
|
viewBinding.tvTabAll.setTypeface(Typeface.create(
|
||||||
|
allDevices ? "sans-serif" : "sans-serif-medium",
|
||||||
|
allDevices ? Typeface.BOLD : Typeface.NORMAL));
|
||||||
|
viewBinding.tvTabPending.setTextColor(getColor(
|
||||||
|
allDevices ? R.color.device_manage_text_primary : R.color.device_manage_orange));
|
||||||
|
|
||||||
|
if (allDevices) {
|
||||||
|
viewBinding.scrollAll.scrollTo(0, 0);
|
||||||
|
} else {
|
||||||
|
viewBinding.scrollPending.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupChipGroup(View... chips) {
|
||||||
|
for (View chip : chips) {
|
||||||
|
applyChipTypeface((TextView) chip, chip.isSelected());
|
||||||
|
chip.setOnClickListener(clicked -> {
|
||||||
|
for (View item : chips) {
|
||||||
|
item.setSelected(item == clicked);
|
||||||
|
applyChipTypeface((TextView) item, item == clicked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyChipTypeface(TextView chip, boolean selected) {
|
||||||
|
chip.setTypeface(Typeface.create(
|
||||||
|
selected ? "sans-serif-medium" : "sans-serif", Typeface.NORMAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onSearch() {
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
if (imm != null) {
|
||||||
|
imm.hideSoftInputFromWindow(viewBinding.etSearch.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
ToastUtil.showShort(mContext, R.string.device_manage_search_unavailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showError(String message) {
|
||||||
|
hideLoading();
|
||||||
|
if (message != null && !message.isEmpty()) {
|
||||||
|
ToastUtil.showShort(mContext, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logOut(BaseBean bean) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.ckkj.griddlebiz.product;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -13,10 +14,11 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.zxing.client.android.MNScanManager;
|
import com.king.camera.scan.CameraScan;
|
||||||
import com.google.zxing.client.android.other.MNScanCallback;
|
|
||||||
import com.ckkj.griddlebiz.R;
|
import com.ckkj.griddlebiz.R;
|
||||||
import com.ckkj.griddlebiz.base.BaseActivity;
|
import com.ckkj.griddlebiz.base.BaseActivity;
|
||||||
import com.ckkj.griddlebiz.databinding.DialogProductInboundManualLayoutBinding;
|
import com.ckkj.griddlebiz.databinding.DialogProductInboundManualLayoutBinding;
|
||||||
@@ -39,6 +41,21 @@ public class ProductInboundActivity extends BaseActivity<ProductInboundLayoutBin
|
|||||||
|
|
||||||
private static final int REQUEST_CAMERA_SCAN = 0x140;
|
private static final int REQUEST_CAMERA_SCAN = 0x140;
|
||||||
|
|
||||||
|
/** 扫码页返回结果;扫码和相册识别都通过 {@link CameraScan#SCAN_RESULT} 回传。 */
|
||||||
|
private final ActivityResultLauncher<Intent> mScanLauncher = registerForActivityResult(
|
||||||
|
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() != RESULT_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent data = result.getData();
|
||||||
|
String code = data == null ? null : data.getStringExtra(CameraScan.SCAN_RESULT);
|
||||||
|
if (TextUtils.isEmpty(code)) {
|
||||||
|
ToastUtil.showShort(mContext, R.string.product_scan_empty);
|
||||||
|
} else {
|
||||||
|
mPresenter.submitCode(code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private Dialog mManualCodeDialog;
|
private Dialog mManualCodeDialog;
|
||||||
private DialogProductInboundManualLayoutBinding mManualBinding;
|
private DialogProductInboundManualLayoutBinding mManualBinding;
|
||||||
|
|
||||||
@@ -66,6 +83,11 @@ public class ProductInboundActivity extends BaseActivity<ProductInboundLayoutBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void requestScanPermission() {
|
private void requestScanPermission() {
|
||||||
|
// 相机在清单中声明为非必需硬件,无相机设备仍可安装和使用手动输入。
|
||||||
|
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
|
||||||
|
ToastUtil.showShort(mContext, R.string.product_camera_unavailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (hasRecordPermission(Manifest.permission.CAMERA)) {
|
if (hasRecordPermission(Manifest.permission.CAMERA)) {
|
||||||
startScan();
|
startScan();
|
||||||
return;
|
return;
|
||||||
@@ -78,32 +100,7 @@ public class ProductInboundActivity extends BaseActivity<ProductInboundLayoutBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startScan() {
|
private void startScan() {
|
||||||
MNScanManager.startScan(this, new MNScanCallback() {
|
mScanLauncher.launch(new Intent(this, ProductScanActivity.class));
|
||||||
@Override
|
|
||||||
public void onActivityResult(int resultCode, Intent data) {
|
|
||||||
switch (resultCode) {
|
|
||||||
case MNScanManager.RESULT_SUCCESS:
|
|
||||||
String success = data == null ? ""
|
|
||||||
: data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
|
|
||||||
if (TextUtils.isEmpty(success)) {
|
|
||||||
ToastUtil.showShort(mContext, R.string.product_scan_empty);
|
|
||||||
} else {
|
|
||||||
mPresenter.submitCode(success);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MNScanManager.RESULT_FAIL:
|
|
||||||
String error = data == null ? ""
|
|
||||||
: data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
|
|
||||||
ToastUtil.showShort(mContext,
|
|
||||||
getString(R.string.product_scan_failed,
|
|
||||||
TextUtils.isEmpty(error) ? "" : error));
|
|
||||||
break;
|
|
||||||
case MNScanManager.RESULT_CANCLE:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,300 @@
|
|||||||
|
package com.ckkj.griddlebiz.product;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.media.ExifInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.PickVisualMediaRequest;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
import com.ckkj.griddlebiz.R;
|
||||||
|
import com.ckkj.griddlebiz.utils.show.ToastUtil;
|
||||||
|
import com.google.zxing.Result;
|
||||||
|
import com.king.camera.scan.AnalyzeResult;
|
||||||
|
import com.king.camera.scan.CameraScan;
|
||||||
|
import com.king.camera.scan.analyze.Analyzer;
|
||||||
|
import com.king.zxing.BarcodeCameraScanActivity;
|
||||||
|
import com.king.zxing.DecodeConfig;
|
||||||
|
import com.king.zxing.analyze.MultiFormatAnalyzer;
|
||||||
|
import com.king.zxing.util.CodeUtils;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品入库扫码页:相机实时扫码,也可从相册选择图片识别。
|
||||||
|
* <p>
|
||||||
|
* 相册使用 AndroidX Photo Picker,不需要读取存储权限;返回结果统一放在
|
||||||
|
* {@link CameraScan#SCAN_RESULT} 中。
|
||||||
|
*/
|
||||||
|
public class ProductScanActivity extends BarcodeCameraScanActivity {
|
||||||
|
|
||||||
|
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
private final ExecutorService mDecodeExecutor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
|
private TextView mTvGallery;
|
||||||
|
private boolean mDecoding;
|
||||||
|
private boolean mResultReturned;
|
||||||
|
|
||||||
|
private final ActivityResultLauncher<PickVisualMediaRequest> mPickImageLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.PickVisualMedia(), this::onImagePicked);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
applyEdgeToEdge();
|
||||||
|
findViewById(R.id.ivScanBack).setOnClickListener(v -> finish());
|
||||||
|
mTvGallery = findViewById(R.id.tvGallery);
|
||||||
|
mTvGallery.setOnClickListener(v -> openPhotoPicker());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyEdgeToEdge() {
|
||||||
|
Window window = getWindow();
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false);
|
||||||
|
window.setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
window.setNavigationBarColor(Color.BLACK);
|
||||||
|
WindowCompat.getInsetsController(window, window.getDecorView())
|
||||||
|
.setAppearanceLightStatusBars(false);
|
||||||
|
|
||||||
|
View root = findViewById(R.id.scanRoot);
|
||||||
|
View topBar = findViewById(R.id.scanTopBar);
|
||||||
|
View bottomBar = findViewById(R.id.scanBottomBar);
|
||||||
|
final int topPadding = topBar.getPaddingTop();
|
||||||
|
final int bottomPadding = bottomBar.getPaddingBottom();
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(root, (v, insets) -> {
|
||||||
|
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
topBar.setPadding(topBar.getPaddingLeft(), topPadding + bars.top,
|
||||||
|
topBar.getPaddingRight(), topBar.getPaddingBottom());
|
||||||
|
bottomBar.setPadding(bottomBar.getPaddingLeft(), bottomBar.getPaddingTop(),
|
||||||
|
bottomBar.getPaddingRight(), bottomPadding + bars.bottom);
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
ViewCompat.requestApplyInsets(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.product_scan_layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Analyzer<Result> createAnalyzer() {
|
||||||
|
// 默认支持 QR_CODE / UPC_A / EAN_13 / CODE_128,覆盖设备外箱常见条码。
|
||||||
|
return new MultiFormatAnalyzer(new DecodeConfig().setFullAreaScan(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initCameraScan(@NonNull CameraScan<Result> cameraScan) {
|
||||||
|
super.initCameraScan(cameraScan);
|
||||||
|
cameraScan.setPlayBeep(true)
|
||||||
|
.setVibrate(true)
|
||||||
|
.setAnalyzeImage(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScanResultCallback(@NonNull AnalyzeResult<Result> result) {
|
||||||
|
Result value = result.getResult();
|
||||||
|
if (value == null || TextUtils.isEmpty(value.getText())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CameraScan<Result> cameraScan = getCameraScan();
|
||||||
|
if (cameraScan != null) {
|
||||||
|
cameraScan.setAnalyzeImage(false);
|
||||||
|
}
|
||||||
|
returnResult(value.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openPhotoPicker() {
|
||||||
|
if (mDecoding) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CameraScan<Result> cameraScan = getCameraScan();
|
||||||
|
if (cameraScan != null) {
|
||||||
|
// 系统相册打开期间暂停识别,避免相机结果提前返回。
|
||||||
|
cameraScan.setAnalyzeImage(false);
|
||||||
|
}
|
||||||
|
mPickImageLauncher.launch(new PickVisualMediaRequest.Builder()
|
||||||
|
.setMediaType(ActivityResultContracts.PickVisualMedia.ImageOnly.INSTANCE)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onImagePicked(@Nullable Uri uri) {
|
||||||
|
if (uri == null) {
|
||||||
|
// 用户取消选择,恢复相机识别。
|
||||||
|
resumeScan();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setDecoding(true);
|
||||||
|
mDecodeExecutor.execute(() -> {
|
||||||
|
String text = decodeImage(uri);
|
||||||
|
mMainHandler.post(() -> {
|
||||||
|
setDecoding(false);
|
||||||
|
if (TextUtils.isEmpty(text)) {
|
||||||
|
ToastUtil.showShort(this, R.string.product_scan_gallery_failed);
|
||||||
|
resumeScan();
|
||||||
|
} else {
|
||||||
|
returnResult(text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String decodeImage(Uri uri) {
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
try {
|
||||||
|
bitmap = loadSampledBitmap(uri);
|
||||||
|
if (bitmap == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
bitmap = applyExifRotation(uri, bitmap);
|
||||||
|
String text = CodeUtils.parseCode(bitmap);
|
||||||
|
if (!TextUtils.isEmpty(text)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
// 相册图片可能本身带旋转角度,逐个方向重试。
|
||||||
|
for (int degrees = 90; degrees < 360; degrees += 90) {
|
||||||
|
Bitmap rotated = rotate(bitmap, degrees);
|
||||||
|
if (rotated == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
text = CodeUtils.parseCode(rotated);
|
||||||
|
if (rotated != bitmap) {
|
||||||
|
rotated.recycle();
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(text)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
if (bitmap != null && !bitmap.isRecycled()) {
|
||||||
|
bitmap.recycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Bitmap loadSampledBitmap(Uri uri) throws Exception {
|
||||||
|
BitmapFactory.Options bounds = new BitmapFactory.Options();
|
||||||
|
bounds.inJustDecodeBounds = true;
|
||||||
|
try (InputStream in = getContentResolver().openInputStream(uri)) {
|
||||||
|
if (in == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BitmapFactory.decodeStream(in, null, bounds);
|
||||||
|
}
|
||||||
|
int sampleSize = 1;
|
||||||
|
int maxSize = Math.max(bounds.outWidth, bounds.outHeight);
|
||||||
|
if (maxSize <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
while (maxSize / sampleSize > 1600) {
|
||||||
|
sampleSize *= 2;
|
||||||
|
}
|
||||||
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
|
options.inSampleSize = sampleSize;
|
||||||
|
try (InputStream in = getContentResolver().openInputStream(uri)) {
|
||||||
|
if (in == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return BitmapFactory.decodeStream(in, null, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap applyExifRotation(Uri uri, Bitmap bitmap) {
|
||||||
|
try (InputStream in = getContentResolver().openInputStream(uri)) {
|
||||||
|
if (in == null) {
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
ExifInterface exif = new ExifInterface(in);
|
||||||
|
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
|
||||||
|
ExifInterface.ORIENTATION_NORMAL);
|
||||||
|
int degrees;
|
||||||
|
switch (orientation) {
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||||
|
degrees = 90;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||||
|
degrees = 180;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||||
|
degrees = 270;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
Bitmap rotated = rotate(bitmap, degrees);
|
||||||
|
return rotated == null ? bitmap : rotated;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Bitmap rotate(Bitmap bitmap, int degrees) {
|
||||||
|
if (degrees % 360 == 0) {
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.postRotate(degrees);
|
||||||
|
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
|
||||||
|
matrix, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDecoding(boolean decoding) {
|
||||||
|
mDecoding = decoding;
|
||||||
|
mTvGallery.setEnabled(!decoding);
|
||||||
|
mTvGallery.setText(decoding ? R.string.product_scan_decoding : R.string.product_scan_gallery);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resumeScan() {
|
||||||
|
CameraScan<Result> cameraScan = getCameraScan();
|
||||||
|
if (cameraScan != null) {
|
||||||
|
cameraScan.setAnalyzeImage(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void returnResult(String text) {
|
||||||
|
if (mResultReturned) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mResultReturned = true;
|
||||||
|
Intent data = new Intent();
|
||||||
|
data.putExtra(CameraScan.SCAN_RESULT, text);
|
||||||
|
setResult(RESULT_OK, data);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
mDecodeExecutor.shutdownNow();
|
||||||
|
mMainHandler.removeCallbacksAndMessages(null);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/src/main/res/color/device_manage_chip_text.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="#FF6900" android:state_selected="true" />
|
||||||
|
<item android:color="#666666" />
|
||||||
|
</selector>
|
||||||
6
app/src/main/res/drawable/device_manage_card_bg.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/white" />
|
||||||
|
<corners android:radius="16dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FFF0E5" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</shape>
|
||||||
6
app/src/main/res/drawable/device_manage_chip_bg.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#F5F5F5" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</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/device_manage_chip_active_bg" android:state_selected="true" />
|
||||||
|
<item android:drawable="@drawable/device_manage_chip_bg" />
|
||||||
|
</selector>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#40FFFFFF" />
|
||||||
|
<corners android:radius="12dp" />
|
||||||
|
</shape>
|
||||||
9
app/src/main/res/drawable/device_manage_search_bg.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/white" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="#DDDDDD" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FDECEC" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#F5F5F5" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#E9F7EF" />
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
</shape>
|
||||||
10
app/src/main/res/drawable/device_manage_summary_note_bg.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FFF0E5" />
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="16dp"
|
||||||
|
android:bottomRightRadius="16dp"
|
||||||
|
android:topLeftRadius="0dp"
|
||||||
|
android:topRightRadius="0dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FF6900" />
|
||||||
|
<corners android:radius="16dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#FF6900" />
|
||||||
|
<corners android:radius="3dp" />
|
||||||
|
</shape>
|
||||||
18
app/src/main/res/drawable/ic_device_manage_warning.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="12dp"
|
||||||
|
android:height="12dp"
|
||||||
|
android:viewportWidth="12"
|
||||||
|
android:viewportHeight="12">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/transparent"
|
||||||
|
android:pathData="M6,1 A5,5 0 1,1 6,11 A5,5 0 1,1 6,1"
|
||||||
|
android:strokeColor="#FF6900"
|
||||||
|
android:strokeWidth="1.1" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF6900"
|
||||||
|
android:pathData="M5.4,3.1h1.2v4.1H5.4z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF6900"
|
||||||
|
android:pathData="M5.4,8.5h1.2v1.2H5.4z" />
|
||||||
|
</vector>
|
||||||
10
app/src/main/res/drawable/ic_product_scan_back.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z" />
|
||||||
|
</vector>
|
||||||
10
app/src/main/res/drawable/ic_product_scan_flash_off.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#66FFFFFF"
|
||||||
|
android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z" />
|
||||||
|
</vector>
|
||||||
10
app/src/main/res/drawable/ic_product_scan_flash_on.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z" />
|
||||||
|
</vector>
|
||||||
10
app/src/main/res/drawable/ic_product_scan_gallery.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
|
||||||
|
</vector>
|
||||||
8
app/src/main/res/drawable/product_scan_bottom_scrim.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<gradient
|
||||||
|
android:angle="270"
|
||||||
|
android:endColor="#B3000000"
|
||||||
|
android:startColor="#00000000" />
|
||||||
|
</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_product_scan_flash_on" android:state_selected="true" />
|
||||||
|
<item android:drawable="@drawable/ic_product_scan_flash_off" />
|
||||||
|
</selector>
|
||||||
6
app/src/main/res/drawable/product_scan_gallery_bg.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="#33FFFFFF" />
|
||||||
|
<corners android:radius="22dp" />
|
||||||
|
</shape>
|
||||||
8
app/src/main/res/drawable/product_scan_top_scrim.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<gradient
|
||||||
|
android:angle="270"
|
||||||
|
android:endColor="#00000000"
|
||||||
|
android:startColor="#99000000" />
|
||||||
|
</shape>
|
||||||
1199
app/src/main/res/layout/device_manage_layout.xml
Normal file
107
app/src/main/res/layout/product_scan_layout.xml
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/scanRoot"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black">
|
||||||
|
|
||||||
|
<androidx.camera.view.PreviewView
|
||||||
|
android:id="@+id/previewView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:importantForAccessibility="no" />
|
||||||
|
|
||||||
|
<com.king.view.viewfinderview.ViewfinderView
|
||||||
|
android:id="@+id/viewfinderView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="140dp"
|
||||||
|
android:background="@drawable/product_scan_top_scrim" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="@drawable/product_scan_bottom_scrim" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/scanTopBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingBottom="6dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivScanBack"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/product_inbound_back"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/ic_product_scan_back" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/product_scan_title"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="17sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivFlashlight"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/product_scan_flashlight"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:src="@drawable/product_scan_flash_selector" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/scanBottomBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:paddingBottom="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvGallery"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:background="@drawable/product_scan_gallery_bg"
|
||||||
|
android:drawableStart="@drawable/ic_product_scan_gallery"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:minWidth="164dp"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"
|
||||||
|
android:text="@string/product_scan_gallery"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvScanTip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="14dp"
|
||||||
|
android:text="@string/product_scan_tip"
|
||||||
|
android:textColor="#B3FFFFFF"
|
||||||
|
android:textSize="13sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
BIN
app/src/main/res/mipmap-xhdpi/icon_device_manage_box.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/icon_device_manage_box_offline.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/icon_device_manage_calendar.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/icon_device_manage_pending.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/icon_device_manage_search.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_device_manage_box.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_device_manage_calendar.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_device_manage_pending.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_device_manage_search.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_device_manage_box.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_device_manage_calendar.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_device_manage_pending.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_device_manage_search.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
39
app/src/main/res/values-en/device_manage_strings.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="device_manage_title">Device Management</string>
|
||||||
|
<string name="device_manage_back">Back</string>
|
||||||
|
<string name="device_manage_tab_all">All Devices</string>
|
||||||
|
<string name="device_manage_tab_pending">Pending Activation</string>
|
||||||
|
|
||||||
|
<string name="device_manage_search_hint">Search by SN / Owner / User</string>
|
||||||
|
<string name="device_manage_search_action">Search</string>
|
||||||
|
<string name="device_manage_search_unavailable">Search is not connected yet</string>
|
||||||
|
<string name="device_manage_filter_all">All</string>
|
||||||
|
<string name="device_manage_filter_online">Online</string>
|
||||||
|
<string name="device_manage_filter_offline">Offline</string>
|
||||||
|
<string name="device_manage_filter_fault">Fault</string>
|
||||||
|
<string name="device_manage_activation_time">Activation Time</string>
|
||||||
|
<string name="device_manage_last_7_days">Last 7 Days</string>
|
||||||
|
<string name="device_manage_last_30_days">Last 30 Days</string>
|
||||||
|
<string name="device_manage_custom">Custom</string>
|
||||||
|
<string name="device_manage_total_devices">%1$d devices total</string>
|
||||||
|
|
||||||
|
<string name="device_manage_status_online">Online</string>
|
||||||
|
<string name="device_manage_status_fault">Fault</string>
|
||||||
|
<string name="device_manage_status_offline">Offline</string>
|
||||||
|
<string name="device_manage_activation_date">Activation Date</string>
|
||||||
|
<string name="device_manage_total_runtime">Total Runtime</string>
|
||||||
|
<string name="device_manage_fault_status">Fault Status</string>
|
||||||
|
<string name="device_manage_fault_normal">Normal</string>
|
||||||
|
|
||||||
|
<string name="device_manage_pending_total_title">Total Pending Activation</string>
|
||||||
|
<string name="device_manage_pending_units">units not activated</string>
|
||||||
|
<string name="device_manage_in_stock">In Stock %1$d</string>
|
||||||
|
<string name="device_manage_sold">Sold %1$d</string>
|
||||||
|
<string name="device_manage_pending_note">Activation is completed by the user; agents can only view and track progress</string>
|
||||||
|
<string name="device_manage_pending_devices">Pending Devices</string>
|
||||||
|
<string name="device_manage_not_activated">Not Activated</string>
|
||||||
|
<string name="device_manage_sold_not_activated">Sold, Not Activated</string>
|
||||||
|
<string name="device_manage_stock_in_date">Stock-In Date</string>
|
||||||
|
<string name="device_manage_activation_time_column">Activation Time</string>
|
||||||
|
</resources>
|
||||||
@@ -11,10 +11,15 @@
|
|||||||
<string name="product_manual_code_close">Close</string>
|
<string name="product_manual_code_close">Close</string>
|
||||||
<string name="product_manual_code_empty">Please enter the QR code number</string>
|
<string name="product_manual_code_empty">Please enter the QR code number</string>
|
||||||
<string name="product_manual_code_submitted">Code submitted: %1$s</string>
|
<string name="product_manual_code_submitted">Code submitted: %1$s</string>
|
||||||
<string name="product_scan_unavailable">Scanner is not connected yet</string>
|
|
||||||
<string name="product_camera_permission_title">Camera Permission</string>
|
<string name="product_camera_permission_title">Camera Permission</string>
|
||||||
<string name="product_camera_permission_content">Product Inbound uses the camera to scan the device outer box barcode. If you decline, you can still enter the SN code manually.</string>
|
<string name="product_camera_permission_content">Product Inbound uses the camera to scan the device outer box barcode. If you decline, you can still enter the SN code manually.</string>
|
||||||
<string name="product_camera_permission_denied">Camera permission was not granted. You can enter the SN code manually.</string>
|
<string name="product_camera_permission_denied">Camera permission was not granted. You can enter the SN code manually.</string>
|
||||||
<string name="product_scan_failed">Scan failed: %1$s</string>
|
<string name="product_camera_unavailable">No camera is available on this device. Please enter the SN code manually.</string>
|
||||||
<string name="product_scan_empty">No barcode was detected. Please try again.</string>
|
<string name="product_scan_empty">No barcode was detected. Please try again.</string>
|
||||||
|
<string name="product_scan_title">Scan to Inbound</string>
|
||||||
|
<string name="product_scan_gallery">Choose from Gallery</string>
|
||||||
|
<string name="product_scan_decoding">Decoding image…</string>
|
||||||
|
<string name="product_scan_tip">Align the barcode within the frame to scan</string>
|
||||||
|
<string name="product_scan_gallery_failed">No barcode was found in the image.</string>
|
||||||
|
<string name="product_scan_flashlight">Flashlight</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
7
app/src/main/res/values/device_manage_colors.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="device_manage_orange">#FF6900</color>
|
||||||
|
<color name="device_manage_text_primary">#222222</color>
|
||||||
|
<color name="device_manage_text_secondary">#666666</color>
|
||||||
|
<color name="device_manage_text_tertiary">#999999</color>
|
||||||
|
</resources>
|
||||||
39
app/src/main/res/values/device_manage_strings.xml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="device_manage_title">设备管理</string>
|
||||||
|
<string name="device_manage_back">返回</string>
|
||||||
|
<string name="device_manage_tab_all">全部设备</string>
|
||||||
|
<string name="device_manage_tab_pending">待激活</string>
|
||||||
|
|
||||||
|
<string name="device_manage_search_hint">搜索 SN / 所有者 / 用户</string>
|
||||||
|
<string name="device_manage_search_action">搜索</string>
|
||||||
|
<string name="device_manage_search_unavailable">搜索功能待接入</string>
|
||||||
|
<string name="device_manage_filter_all">全部</string>
|
||||||
|
<string name="device_manage_filter_online">在线</string>
|
||||||
|
<string name="device_manage_filter_offline">离线</string>
|
||||||
|
<string name="device_manage_filter_fault">故障</string>
|
||||||
|
<string name="device_manage_activation_time">激活时间</string>
|
||||||
|
<string name="device_manage_last_7_days">近 7 天</string>
|
||||||
|
<string name="device_manage_last_30_days">近 30 天</string>
|
||||||
|
<string name="device_manage_custom">自定义</string>
|
||||||
|
<string name="device_manage_total_devices">共 %1$d 台设备</string>
|
||||||
|
|
||||||
|
<string name="device_manage_status_online">在线</string>
|
||||||
|
<string name="device_manage_status_fault">故障</string>
|
||||||
|
<string name="device_manage_status_offline">离线</string>
|
||||||
|
<string name="device_manage_activation_date">激活日期</string>
|
||||||
|
<string name="device_manage_total_runtime">累计运行</string>
|
||||||
|
<string name="device_manage_fault_status">故障状态</string>
|
||||||
|
<string name="device_manage_fault_normal">正常</string>
|
||||||
|
|
||||||
|
<string name="device_manage_pending_total_title">待激活总数</string>
|
||||||
|
<string name="device_manage_pending_units">台未激活</string>
|
||||||
|
<string name="device_manage_in_stock">库存 %1$d</string>
|
||||||
|
<string name="device_manage_sold">已售 %1$d</string>
|
||||||
|
<string name="device_manage_pending_note">激活由用户完成,代理商仅可查看和跟进进度</string>
|
||||||
|
<string name="device_manage_pending_devices">待激活设备</string>
|
||||||
|
<string name="device_manage_not_activated">未激活</string>
|
||||||
|
<string name="device_manage_sold_not_activated">已售,未激活</string>
|
||||||
|
<string name="device_manage_stock_in_date">入库日期</string>
|
||||||
|
<string name="device_manage_activation_time_column">激活时间</string>
|
||||||
|
</resources>
|
||||||
@@ -11,10 +11,15 @@
|
|||||||
<string name="product_manual_code_close">关闭</string>
|
<string name="product_manual_code_close">关闭</string>
|
||||||
<string name="product_manual_code_empty">请输入二维码编号</string>
|
<string name="product_manual_code_empty">请输入二维码编号</string>
|
||||||
<string name="product_manual_code_submitted">已提交编码:%1$s</string>
|
<string name="product_manual_code_submitted">已提交编码:%1$s</string>
|
||||||
<string name="product_scan_unavailable">扫码能力待接入</string>
|
|
||||||
<string name="product_camera_permission_title">相机权限使用说明</string>
|
<string name="product_camera_permission_title">相机权限使用说明</string>
|
||||||
<string name="product_camera_permission_content">商品入库需要使用相机扫描设备外箱条码。拒绝或取消授权不影响手动输入 SN 码。</string>
|
<string name="product_camera_permission_content">商品入库需要使用相机扫描设备外箱条码。拒绝或取消授权不影响手动输入 SN 码。</string>
|
||||||
<string name="product_camera_permission_denied">未获得相机权限,可手动输入 SN 码</string>
|
<string name="product_camera_permission_denied">未获得相机权限,可手动输入 SN 码</string>
|
||||||
<string name="product_scan_failed">扫码失败:%1$s</string>
|
<string name="product_camera_unavailable">当前设备没有可用相机,请手动输入 SN 码</string>
|
||||||
<string name="product_scan_empty">未识别到条码,请重试</string>
|
<string name="product_scan_empty">未识别到条码,请重试</string>
|
||||||
|
<string name="product_scan_title">扫码入库</string>
|
||||||
|
<string name="product_scan_gallery">从相册选择</string>
|
||||||
|
<string name="product_scan_decoding">正在识别图片…</string>
|
||||||
|
<string name="product_scan_tip">将条码放入框内,即可自动识别</string>
|
||||||
|
<string name="product_scan_gallery_failed">未从图片中识别到条码</string>
|
||||||
|
<string name="product_scan_flashlight">手电筒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -10,4 +10,14 @@
|
|||||||
<item name="android:backgroundDimAmount">0.6</item>
|
<item name="android:backgroundDimAmount">0.6</item>
|
||||||
<item name="android:windowCloseOnTouchOutside">true</item>
|
<item name="android:windowCloseOnTouchOutside">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- 扫码页:相机预览铺满全屏,状态栏透明。 -->
|
||||||
|
<style name="ProductScanTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="android:windowBackground">@android:color/black</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:navigationBarColor">@android:color/black</item>
|
||||||
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
|
<item name="android:windowActionBar">false</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||