Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
applicationId = "com.example.heart_rate_monitor_mobile"
minSdk = 27
targetSdk = 35
versionCode = 5
versionName = "1.7"
versionCode = 6
versionName = "1.8"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
signingConfig = signingConfigs.getByName("release")
Expand Down Expand Up @@ -92,16 +92,14 @@ dependencies {
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)

implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

// ViewModel and LiveData for modern UI development
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-process:2.7.0")
implementation("androidx.activity:activity-ktx:1.9.0")

// Kable for Bluetooth LE
implementation("com.juul.kable:core-android:0.32.0")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
android:name=".HeartRateApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HeartRateMonitorMobile"
tools:targetApi="31">
tools:targetApi="35">

<service
android:name=".service.BleService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class MainActivity : BaseActivity() {
binding.scanButton.setOnClickListener { viewModel.startScan() }
binding.disconnectButton.setOnClickListener { viewModel.disconnectDevice() }
binding.floatingWindowButton.setOnClickListener { toggleFloatingWindow() }
binding.historyCard.setOnClickListener {
binding.historyButton.setOnClickListener {
startActivity(Intent(this, HistoryActivity::class.java))
}
binding.bottomNavigation.setOnItemSelectedListener { item ->
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_history.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M13,3a9,9 0 0 0 -9,9H1l3.89,3.89 0.07,0.14L9,12H6c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42A8.954,8.954 0 0 0 13,21a9,9 0 0 0 0,-18zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08V8H12z"
android:fillColor="#000000"/>
</vector>
59 changes: 12 additions & 47 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
app:srcCompat="@drawable/ic_floating_window_off"
app:tint="@android:color/white" />

<ImageButton
android:id="@+id/historyButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="查看历史记录"
android:padding="12dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_history"
app:tint="?attr/colorOnSurface" />

<ImageButton
android:id="@+id/scanButton"
android:layout_width="48dp"
Expand Down Expand Up @@ -245,52 +256,6 @@
tools:itemCount="3"
tools:listitem="@layout/list_item_device" />

<androidx.cardview.widget.CardView
android:id="@+id/historyCard"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="16dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardBackgroundColor="?attr/colorSurface"
app:cardCornerRadius="12dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/devicesRecyclerView"
app:layout_constraintVertical_bias="0.0">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingHorizontal="16dp">

<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_info"
app:tint="?attr/colorPrimary" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="查看历史记录"
android:textColor="?attr/colorOnSurface"
android:textSize="16sp" />

<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_arrow_forward"
app:tint="?attr/colorOnSurfaceVariant" />
</LinearLayout>
</androidx.cardview.widget.CardView>

<Button
android:id="@+id/disconnectButton"
android:layout_width="wrap_content"
Expand All @@ -305,7 +270,7 @@
app:icon="@drawable/ic_bluetooth_disabled"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/historyCard" />
app:layout_constraintTop_toBottomOf="@+id/devicesRecyclerView" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
Expand Down
Loading