diff --git a/bj_power_app/.gitignore b/bj_power_app/.gitignore new file mode 100644 index 0000000..d79d0f1 --- /dev/null +++ b/bj_power_app/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties +app/build diff --git a/bj_power_app/app/build.gradle b/bj_power_app/app/build.gradle new file mode 100644 index 0000000..7da2b86 --- /dev/null +++ b/bj_power_app/app/build.gradle @@ -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' +} diff --git a/bj_power_app/app/proguard-rules.pro b/bj_power_app/app/proguard-rules.pro new file mode 100644 index 0000000..4dde71a --- /dev/null +++ b/bj_power_app/app/proguard-rules.pro @@ -0,0 +1,7 @@ +# 保留 ZXing 相关类(扫码依赖反射/系统组件) +-keep class com.journeyapps.** { *; } +-keep class com.google.zxing.** { *; } + +# OkHttp +-dontwarn okhttp3.** +-dontwarn okio.** diff --git a/bj_power_app/app/src/main/AndroidManifest.xml b/bj_power_app/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e567bb5 --- /dev/null +++ b/bj_power_app/app/src/main/AndroidManifest.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/java/com/bjpower/app/AppConfig.java b/bj_power_app/app/src/main/java/com/bjpower/app/AppConfig.java new file mode 100644 index 0000000..aaa8804 --- /dev/null +++ b/bj_power_app/app/src/main/java/com/bjpower/app/AppConfig.java @@ -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; + } +} diff --git a/bj_power_app/app/src/main/java/com/bjpower/app/LoginActivity.java b/bj_power_app/app/src/main/java/com/bjpower/app/LoginActivity.java new file mode 100644 index 0000000..68bfad9 --- /dev/null +++ b/bj_power_app/app/src/main/java/com/bjpower/app/LoginActivity.java @@ -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(); + } +} diff --git a/bj_power_app/app/src/main/java/com/bjpower/app/MainActivity.java b/bj_power_app/app/src/main/java/com/bjpower/app/MainActivity.java new file mode 100644 index 0000000..349e739 --- /dev/null +++ b/bj_power_app/app/src/main/java/com/bjpower/app/MainActivity.java @@ -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=,渲染工件详情与工序时间线到 tv_workpiece_result + btnQuery.setOnClickListener(v -> tipSkeleton()); + // TODO 接入系统相机 + FileProvider,拍照结果写入 iv_photo / tv_photo_state + btnTakePhoto.setOnClickListener(v -> tipSkeleton()); + // TODO 接入 POST /api/v1/inspections/upload(multipart,字段名 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(); + } +} diff --git a/bj_power_app/app/src/main/java/com/bjpower/app/SettingsActivity.java b/bj_power_app/app/src/main/java/com/bjpower/app/SettingsActivity.java new file mode 100644 index 0000000..b48aac6 --- /dev/null +++ b/bj_power_app/app/src/main/java/com/bjpower/app/SettingsActivity.java @@ -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(); + } +} diff --git a/bj_power_app/app/src/main/res/drawable/ic_launcher.xml b/bj_power_app/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 0000000..8b9e0c0 --- /dev/null +++ b/bj_power_app/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/res/layout/activity_login.xml b/bj_power_app/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..e2ff6dd --- /dev/null +++ b/bj_power_app/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/res/layout/activity_main.xml b/bj_power_app/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..540bd94 --- /dev/null +++ b/bj_power_app/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/res/layout/activity_settings.xml b/bj_power_app/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..cc70d52 --- /dev/null +++ b/bj_power_app/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/res/values/colors.xml b/bj_power_app/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..4616268 --- /dev/null +++ b/bj_power_app/app/src/main/res/values/colors.xml @@ -0,0 +1,11 @@ + + + #1565C0 + #0D47A1 + #FFFFFF + #F5F6F8 + #FFFFFF + #E0E3E8 + #1F2937 + #6B7280 + diff --git a/bj_power_app/app/src/main/res/values/strings.xml b/bj_power_app/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..aaba3d4 --- /dev/null +++ b/bj_power_app/app/src/main/res/values/strings.xml @@ -0,0 +1,35 @@ + + + bj_power 扫码枪 + 登录 + 设置 + + + 保存 + 取消 + 返回 + + + 服务器地址 + 例如 192.168.1.100:8888 + 账号 + 请输入账号 + 密码 + 请输入密码 + 登录 + 恢复默认地址 + 当前服务器:%1$s + + + 扫 码 + 切换账号 + 工件 SN + 扫码后自动填入,也可手动输入 + 查询工件信息 + 拍照 + 上传照片 + 工件信息 + 现场照片 + 尚未拍照 + 骨架阶段:该功能待接入 + diff --git a/bj_power_app/app/src/main/res/values/themes.xml b/bj_power_app/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..2ffb4f0 --- /dev/null +++ b/bj_power_app/app/src/main/res/values/themes.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/bj_power_app/app/src/main/res/xml/file_paths.xml b/bj_power_app/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..6f31521 --- /dev/null +++ b/bj_power_app/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/bj_power_app/app/src/main/res/xml/network_security_config.xml b/bj_power_app/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000..dd15480 --- /dev/null +++ b/bj_power_app/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bj_power_app/build.gradle b/bj_power_app/build.gradle new file mode 100644 index 0000000..df27e30 --- /dev/null +++ b/bj_power_app/build.gradle @@ -0,0 +1,4 @@ +// 顶层构建文件:只声明插件版本,具体配置在 app/build.gradle +plugins { + id 'com.android.application' version '8.5.2' apply false +} diff --git a/bj_power_app/gradle.properties b/bj_power_app/gradle.properties new file mode 100644 index 0000000..98946d4 --- /dev/null +++ b/bj_power_app/gradle.properties @@ -0,0 +1,6 @@ +# Gradle 构建参数 +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# 使用 AndroidX(zxing-android-embedded / material 均基于 AndroidX) +android.useAndroidX=true +# 非传递 R 类,减小方法数 +android.nonTransitiveRClass=true diff --git a/bj_power_app/gradle/wrapper/gradle-wrapper.jar b/bj_power_app/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e644113 Binary files /dev/null and b/bj_power_app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/bj_power_app/gradle/wrapper/gradle-wrapper.properties b/bj_power_app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b82aa23 --- /dev/null +++ b/bj_power_app/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/bj_power_app/gradlew b/bj_power_app/gradlew new file mode 100644 index 0000000..41e2729 --- /dev/null +++ b/bj_power_app/gradlew @@ -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" "$@" diff --git a/bj_power_app/gradlew.bat b/bj_power_app/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/bj_power_app/gradlew.bat @@ -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 diff --git a/bj_power_app/settings.gradle b/bj_power_app/settings.gradle new file mode 100644 index 0000000..32d6b00 --- /dev/null +++ b/bj_power_app/settings.gradle @@ -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'