feat: 初始化bj_power_app扫码app项目骨架

This commit is contained in:
zhoujianjin
2026-09-11 16:20:15 +08:00
parent 0ab21b1234
commit 0b3e06f86f
24 changed files with 1158 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
app/build
+43
View File
@@ -0,0 +1,43 @@
plugins {
id 'com.android.application'
}
android {
namespace 'com.bjpower.app'
compileSdk 34
defaultConfig {
applicationId "com.bjpower.app"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
packagingOptions {
resources.excludes += ['META-INF/DEPENDENCIES', 'META-INF/NOTICE', 'META-INF/LICENSE']
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
// 扫码:ZXing 嵌入式(纯 Java、离线、不依赖 Google 服务)
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
// 网络:OkHttp
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
+7
View File
@@ -0,0 +1,7 @@
# 保留 ZXing 相关类(扫码依赖反射/系统组件)
-keep class com.journeyapps.** { *; }
-keep class com.google.zxing.** { *; }
# OkHttp
-dontwarn okhttp3.**
-dontwarn okio.**
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/Theme.BjPowerApp">
<activity
android:name=".LoginActivity"
android:exported="false"
android:label="@string/title_login" />
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_settings" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 拍照输出文件用 FileProvider 暴露给系统相机 -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
@@ -0,0 +1,65 @@
package com.bjpower.app;
import android.content.Context;
import android.content.SharedPreferences;
/**
* 本地配置持久化:服务器地址、登录令牌、账号。
* 骨架阶段仅提供读写能力,网络层后续接入。
*/
public final class AppConfig {
private static final String SP_NAME = "bj_power_app";
private static final String KEY_BASE_URL = "base_url";
private static final String KEY_TOKEN = "access_token";
private static final String KEY_USERNAME = "username";
/** 默认服务器地址(MES 服务,端口 8888),可在登录页或设置页修改。 */
public static final String DEFAULT_BASE_URL = "http://192.168.1.100:8888";
private AppConfig() {
}
private static SharedPreferences sp(Context ctx) {
return ctx.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
}
public static String getBaseUrl(Context ctx) {
return sp(ctx).getString(KEY_BASE_URL, DEFAULT_BASE_URL);
}
public static void setBaseUrl(Context ctx, String baseUrl) {
sp(ctx).edit().putString(KEY_BASE_URL, normalize(baseUrl)).apply();
}
public static String getToken(Context ctx) {
return sp(ctx).getString(KEY_TOKEN, "");
}
public static void setToken(Context ctx, String token) {
sp(ctx).edit().putString(KEY_TOKEN, token == null ? "" : token).apply();
}
public static String getUsername(Context ctx) {
return sp(ctx).getString(KEY_USERNAME, "");
}
public static void setUsername(Context ctx, String username) {
sp(ctx).edit().putString(KEY_USERNAME, username == null ? "" : username).apply();
}
/** 规整地址:允许只填 192.168.1.100:8888,自动补 http:// 并去掉末尾斜杠。 */
public static String normalize(String baseUrl) {
String url = baseUrl == null ? "" : baseUrl.trim();
if (url.isEmpty()) {
return DEFAULT_BASE_URL;
}
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "http://" + url;
}
while (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
return url;
}
}
@@ -0,0 +1,62 @@
package com.bjpower.app;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
/**
* 登录页骨架:服务器地址 + MES 账号。
* TODO 接入 POST /api/v1/login,保存 accessToken 后再进入主界面。
*/
public class LoginActivity extends AppCompatActivity {
private TextInputEditText etBaseUrl;
private TextInputEditText etUsername;
private TextInputEditText etPassword;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
etBaseUrl = findViewById(R.id.et_base_url);
etUsername = findViewById(R.id.et_username);
etPassword = findViewById(R.id.et_password);
MaterialButton btnLogin = findViewById(R.id.btn_login);
etBaseUrl.setText(AppConfig.getBaseUrl(this));
etUsername.setText(AppConfig.getUsername(this));
btnLogin.setOnClickListener(v -> doLogin());
}
private void doLogin() {
String baseUrl = AppConfig.normalize(text(etBaseUrl));
AppConfig.setBaseUrl(this, baseUrl);
etBaseUrl.setText(baseUrl);
String username = text(etUsername);
String password = text(etPassword);
if (username.isEmpty() || password.isEmpty()) {
Toast.makeText(this, R.string.tip_skeleton, Toast.LENGTH_SHORT).show();
return;
}
AppConfig.setUsername(this, username);
// TODO 调用 /api/v1/login 校验账号密码并保存 accessToken
Toast.makeText(this, R.string.tip_skeleton, Toast.LENGTH_SHORT).show();
startActivity(new Intent(this, MainActivity.class));
finish();
}
private static String text(TextInputEditText et) {
return et.getText() == null ? "" : et.getText().toString().trim();
}
}
@@ -0,0 +1,69 @@
package com.bjpower.app;
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.button.MaterialButton;
/**
* 主界面骨架:扫码入口 + 工件信息 + 现场照片。
* 骨架阶段各业务按钮仅做占位提示,逻辑待后续接入。
*/
public class MainActivity extends AppCompatActivity {
private TextView tvServer;
private EditText etSn;
private TextView tvWorkpieceResult;
private ImageView ivPhoto;
private TextView tvPhotoState;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvServer = findViewById(R.id.tv_server);
etSn = findViewById(R.id.et_sn);
tvWorkpieceResult = findViewById(R.id.tv_workpiece_result);
ivPhoto = findViewById(R.id.iv_photo);
tvPhotoState = findViewById(R.id.tv_photo_state);
MaterialButton btnScan = findViewById(R.id.btn_scan);
MaterialButton btnQuery = findViewById(R.id.btn_query);
MaterialButton btnTakePhoto = findViewById(R.id.btn_take_photo);
MaterialButton btnUploadPhoto = findViewById(R.id.btn_upload_photo);
MaterialButton btnSettings = findViewById(R.id.btn_settings);
MaterialButton btnSwitchAccount = findViewById(R.id.btn_switch_account);
btnSettings.setOnClickListener(v ->
startActivity(new Intent(this, SettingsActivity.class)));
btnSwitchAccount.setOnClickListener(v ->
startActivity(new Intent(this, LoginActivity.class)));
// TODO 接入 ZXing 扫码,扫到结果后写入 et_sn 并触发查询
btnScan.setOnClickListener(v -> tipSkeleton());
// TODO 接入 GET /api/v1/trace?sn=<SN>,渲染工件详情与工序时间线到 tv_workpiece_result
btnQuery.setOnClickListener(v -> tipSkeleton());
// TODO 接入系统相机 + FileProvider,拍照结果写入 iv_photo / tv_photo_state
btnTakePhoto.setOnClickListener(v -> tipSkeleton());
// TODO 接入 POST /api/v1/inspections/uploadmultipart,字段名 file
btnUploadPhoto.setOnClickListener(v -> tipSkeleton());
}
@Override
protected void onResume() {
super.onResume();
tvServer.setText(getString(R.string.label_current_server, AppConfig.getBaseUrl(this)));
}
private void tipSkeleton() {
Toast.makeText(this, R.string.tip_skeleton, Toast.LENGTH_SHORT).show();
}
}
@@ -0,0 +1,46 @@
package com.bjpower.app;
import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
/**
* 设置页骨架:仅配置服务器地址(MES 地址,形如 http://192.168.1.100:8888)。
*/
public class SettingsActivity extends AppCompatActivity {
private TextInputEditText etBaseUrl;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
etBaseUrl = findViewById(R.id.et_base_url);
MaterialButton btnSave = findViewById(R.id.btn_save);
MaterialButton btnReset = findViewById(R.id.btn_reset);
etBaseUrl.setText(AppConfig.getBaseUrl(this));
btnSave.setOnClickListener(v -> {
AppConfig.setBaseUrl(this, text());
etBaseUrl.setText(AppConfig.getBaseUrl(this));
Toast.makeText(this, R.string.action_save, Toast.LENGTH_SHORT).show();
finish();
});
btnReset.setOnClickListener(v -> {
AppConfig.setBaseUrl(this, AppConfig.DEFAULT_BASE_URL);
etBaseUrl.setText(AppConfig.getBaseUrl(this));
});
}
private String text() {
return etBaseUrl.getText() == null ? "" : etBaseUrl.getText().toString();
}
}
@@ -0,0 +1,34 @@
<?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="#1565C0"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M24,36h6v36h-6z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M34,36h3v36h-3z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M41,36h7v36h-7z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M52,36h3v36h-3z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M59,36h6v36h-6z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M69,36h3v36h-3z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M76,36h8v36h-8z" />
</vector>
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="@color/bg"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="24dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/app_name"
android:textColor="@color/text_primary"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
style="@style/Text.BjPower.Label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_login" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="@string/label_base_url">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_base_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textUri"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/label_username">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="text"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/label_password"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textPassword"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="24dp"
android:text="@string/action_login" />
</LinearLayout>
</ScrollView>
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="@color/bg"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- 顶部:标题 + 切换账号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/app_name"
android:textColor="@color/text_primary"
android:textSize="20sp"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_settings"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:text="@string/title_settings"
android:textColor="@color/brand" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_switch_account"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:text="@string/action_switch_account"
android:textColor="@color/brand" />
</LinearLayout>
<TextView
android:id="@+id/tv_server"
style="@style/Text.BjPower.Label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp" />
<!-- 扫码 -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_scan"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginTop="14dp"
android:text="@string/action_scan"
android:textSize="20sp"
app:cornerRadius="10dp" />
<!-- 工件查询卡片 -->
<com.google.android.material.card.MaterialCardView
style="@style/Widget.BjPower.Card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="14dp">
<TextView
style="@style/Text.BjPower.Value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/section_workpiece"
android:textStyle="bold" />
<EditText
android:id="@+id/et_sn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="@string/hint_sn"
android:importantForAutofill="no"
android:inputType="text"
android:singleLine="true" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_query"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/action_query" />
<!-- TODO 待接入 /api/v1/trace?sn= 后,这里渲染工件详情与工序时间线 -->
<TextView
android:id="@+id/tv_workpiece_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:lineSpacingExtra="4dp"
android:text="@string/tip_skeleton"
android:textColor="@color/text_secondary"
android:textSize="14sp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 现场照片卡片 -->
<com.google.android.material.card.MaterialCardView
style="@style/Widget.BjPower.Card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="14dp">
<TextView
style="@style/Text.BjPower.Value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/section_photo"
android:textStyle="bold" />
<ImageView
android:id="@+id/iv_photo"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginTop="10dp"
android:background="@color/bg"
android:contentDescription="@string/section_photo"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/tv_photo_state"
style="@style/Text.BjPower.Label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/photo_none" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_take_photo"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_take_photo" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_upload_photo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="@string/action_upload_photo" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>
@@ -0,0 +1,37 @@
<?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:background="@color/bg"
android:orientation="vertical"
android:padding="16dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_base_url">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_base_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textUri"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_save" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_reset"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/action_reset_default" />
</LinearLayout>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="brand">#1565C0</color>
<color name="brand_dark">#0D47A1</color>
<color name="white">#FFFFFF</color>
<color name="bg">#F5F6F8</color>
<color name="card">#FFFFFF</color>
<color name="stroke">#E0E3E8</color>
<color name="text_primary">#1F2937</color>
<color name="text_secondary">#6B7280</color>
</resources>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">bj_power 扫码枪</string>
<string name="title_login">登录</string>
<string name="title_settings">设置</string>
<!-- 通用 -->
<string name="action_save">保存</string>
<string name="action_cancel">取消</string>
<string name="action_back">返回</string>
<!-- 登录 / 设置 -->
<string name="label_base_url">服务器地址</string>
<string name="hint_base_url">例如 192.168.1.100:8888</string>
<string name="label_username">账号</string>
<string name="hint_username">请输入账号</string>
<string name="label_password">密码</string>
<string name="hint_password">请输入密码</string>
<string name="action_login">登录</string>
<string name="action_reset_default">恢复默认地址</string>
<string name="label_current_server">当前服务器:%1$s</string>
<!-- 主界面 -->
<string name="action_scan">扫 码</string>
<string name="action_switch_account">切换账号</string>
<string name="label_sn">工件 SN</string>
<string name="hint_sn">扫码后自动填入,也可手动输入</string>
<string name="action_query">查询工件信息</string>
<string name="action_take_photo">拍照</string>
<string name="action_upload_photo">上传照片</string>
<string name="section_workpiece">工件信息</string>
<string name="section_photo">现场照片</string>
<string name="photo_none">尚未拍照</string>
<string name="tip_skeleton">骨架阶段:该功能待接入</string>
</resources>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.BjPowerApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/brand</item>
<item name="colorPrimaryVariant">@color/brand_dark</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorSecondary">@color/brand</item>
<item name="colorOnSecondary">@color/white</item>
<item name="android:statusBarColor">@color/brand_dark</item>
<item name="android:windowBackground">@color/bg</item>
</style>
<!-- 卡片:白底 + 细描边 + 圆角 -->
<style name="Widget.BjPower.Card" parent="Widget.MaterialComponents.CardView">
<item name="cardBackgroundColor">@color/card</item>
<item name="cardCornerRadius">10dp</item>
<item name="cardElevation">0dp</item>
<item name="strokeColor">@color/stroke</item>
<item name="strokeWidth">1dp</item>
</style>
<style name="Text.BjPower.Label" parent="">
<item name="android:textColor">@color/text_secondary</item>
<item name="android:textSize">13sp</item>
</style>
<style name="Text.BjPower.Value" parent="">
<item name="android:textColor">@color/text_primary</item>
<item name="android:textSize">16sp</item>
</style>
</resources>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<!-- 拍照原图存放目录:getCacheDir()/images -->
<cache-path
name="images"
path="images/" />
</paths>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 内网 MES 走 http(如 http://192.168.x.x:8888),Android 9+ 默认禁止明文,这里放开 -->
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
+4
View File
@@ -0,0 +1,4 @@
// 顶层构建文件:只声明插件版本,具体配置在 app/build.gradle
plugins {
id 'com.android.application' version '8.5.2' apply false
}
+6
View File
@@ -0,0 +1,6 @@
# Gradle 构建参数
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# 使用 AndroidXzxing-android-embedded / material 均基于 AndroidX
android.useAndroidX=true
# 非传递 R 类,减小方法数
android.nonTransitiveRClass=true
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+249
View File
@@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original 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
#
# https://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.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+22
View File
@@ -0,0 +1,22 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
}
}
rootProject.name = "bj_power_app"
include ':app'