Compare commits

..

No commits in common. 'cad4b58a465c395f6d8288a279e4747335160e3d' and '9707314aeeefd93c37bf2e555fb5b757a0e4f19c' have entirely different histories.

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
<bytecodeTargetLevel target="21" />
</component>
</project>

@ -6,7 +6,7 @@
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="corretto-17" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectInspectionProfilesVisibleTreeState">
@ -35,7 +34,7 @@
</profile-state>
</entry>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -1,48 +0,0 @@
plugins {
alias(libs.plugins.android.application)
}
android {
namespace 'com.example.mobile_pda'
compileSdk 36
defaultConfig {
applicationId "com.example.mobile_pda"
minSdk 26
targetSdk 36
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.activity
implementation libs.constraintlayout
// Lifecycle components
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.7.0'
implementation 'androidx.lifecycle:lifecycle-livedata:2.7.0'
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
}

@ -0,0 +1,44 @@
plugins {
alias(libs.plugins.android.application)
}
android {
namespace = "com.example.mobile_pda"
compileSdk {
version = release(36)
}
defaultConfig {
applicationId = "com.example.mobile_pda"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}

@ -12,7 +12,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.Mobile_PDA">
<activity
android:name=".ui.main.MainActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

@ -0,0 +1,78 @@
package com.example.mobile_pda;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
// 顶部按钮组件 -->开始、暂停、主页图标
private Button btnStartHeader, btnPauseHeader;
private ImageButton btnHome;
// 表单输入组件 --> 资源、产品条码、工单等数据项
private EditText etResource, etProductBarcode, etWorkOrder, etOpStep, etWorkNum, etProcess, etStatus, etWorkshop, etStartTime, etEndTime;
// SFC(生产控制) 区域按钮 --> 移除选项、移除全部
private TextView btnRemoveSelected, btnRemoveAll;
// 底部操作区按钮 --> 互检、开始、刀具、辅料、异常、装配、自检、首检、完成
private Button btnActionHujian, btnActionStart, btnActionTool, btnActionAux;
private Button btnActionException, btnActionAssemble, btnActionSelfCheck, btnActionFirstCheck, btnActionFinish;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
// 启用全屏显示,适配系统栏(状态栏/导航栏)宽度占位
setContentView(R.layout.activity_main);
initViews();
setupListeners();
}
private void initViews() {
// 顶部导航栏初始化
btnStartHeader = findViewById(R.id.btn_start_header);
btnPauseHeader = findViewById(R.id.btn_pause_header);
btnHome = findViewById(R.id.btn_home);
// 核心表单区域初始化
etResource = findViewById(R.id.et_resource);
etProductBarcode = findViewById(R.id.et_product_barcode);
etWorkOrder = findViewById(R.id.et_work_order);
etOpStep = findViewById(R.id.et_op_step);
etWorkNum = findViewById(R.id.et_work_num);
etProcess = findViewById(R.id.et_process);
etStatus = findViewById(R.id.et_status);
etWorkshop = findViewById(R.id.et_workshop);
etStartTime = findViewById(R.id.et_start_time);
etEndTime = findViewById(R.id.et_end_time);
// SFC 列表区域初始化
btnRemoveSelected = findViewById(R.id.btn_remove_selected);
btnRemoveAll = findViewById(R.id.btn_remove_all);
// 底部快捷操作按钮初始化
btnActionHujian = findViewById(R.id.btn_action_hujian);
btnActionStart = findViewById(R.id.btn_action_start);
btnActionTool = findViewById(R.id.btn_action_tool);
btnActionAux = findViewById(R.id.btn_action_aux);
btnActionException = findViewById(R.id.btn_action_exception);
btnActionAssemble = findViewById(R.id.btn_action_assemble);
btnActionSelfCheck = findViewById(R.id.btn_action_self_check);
btnActionFirstCheck = findViewById(R.id.btn_action_first_check);
btnActionFinish = findViewById(R.id.btn_action_finish);
}
private void setupListeners() {
btnActionStart.setOnClickListener(v -> Toast.makeText(this, "Start Clicked", Toast.LENGTH_SHORT).show());
btnActionFinish.setOnClickListener(v -> Toast.makeText(this, "Finish Clicked", Toast.LENGTH_SHORT).show());
}
}

@ -1,67 +0,0 @@
package com.example.mobile_pda.ui.main;
import android.os.Bundle;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import com.example.mobile_pda.R;
import com.example.mobile_pda.databinding.ActivityMainBinding;
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
private MainViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
// 使用 ViewBinding 极简初始化,淘汰 findViewById
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// 初始化 ViewModel状态隔离
viewModel = new ViewModelProvider(this).get(MainViewModel.class);
setupObservers();
setupListeners();
}
private void setupObservers() {
// 观察运行状态的变化
viewModel.getIsRunning().observe(this, isRunning -> {
if (isRunning) {
// UI状态随着数据改变只是模拟示例
binding.btnStartHeader.setEnabled(false);
binding.btnPauseHeader.setEnabled(true);
} else {
binding.btnStartHeader.setEnabled(true);
binding.btnPauseHeader.setEnabled(false);
}
});
}
private void setupListeners() {
// 使用 Binding 直接访问控件
binding.btnActionStart.setOnClickListener(v -> {
Toast.makeText(this, getString(R.string.toast_start_clicked), Toast.LENGTH_SHORT).show();
viewModel.startOperation();
});
binding.btnActionFinish.setOnClickListener(v -> {
Toast.makeText(this, getString(R.string.toast_finish_clicked), Toast.LENGTH_SHORT).show();
viewModel.finishOperation();
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// 清理 binding 引用防止内存泄漏
binding = null;
}
}

@ -1,23 +0,0 @@
package com.example.mobile_pda.ui.main;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class MainViewModel extends ViewModel {
// 模拟的业务运行状态LiveData实现生命周期感知
private final MutableLiveData<Boolean> isRunning = new MutableLiveData<>(false);
public LiveData<Boolean> getIsRunning() {
return isRunning;
}
public void startOperation() {
isRunning.setValue(true);
}
public void finishOperation() {
isRunning.setValue(false);
}
}

@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mobile_PDA</string>
<string name="toast_start_clicked">开始被点击</string>
<string name="toast_finish_clicked">完成被点击</string>
</resources>

@ -1,4 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
}
}

@ -20,4 +20,5 @@ dependencyResolutionManagement {
}
rootProject.name = "Mobile_PDA"
include ':app'
include(":app")
Loading…
Cancel
Save