Best_2048_Android_9-13/app/build.gradle.kts
Muyue 1842213cac Refactor: Clean codebase, add MP features, improve notifications & robustness
This commit incorporates significant improvements and cleaning across the Best 2048 application.

**Code Cleaning & Refactoring:**
- Removed comments, logs (Log.*, System.out), and unused imports/variables/methods from all core Java files:
    - MainActivity, Game, GameStats, MultiplayerActivity, NotificationHelper,
      OnSwipeTouchListener, ApiClient, ApiService, data classes.
- Removed NotificationService.java as it's replaced by WorkManager.

**Notifications:**
- Replaced the unreliable Handler-based NotificationService with a robust WorkManager implementation (NotificationWorker.java).
- MainActivity now schedules/cancels periodic work for notifications correctly based on user preference and permissions.
- Removed the <service> declaration for NotificationService from AndroidManifest.xml.
- Requires 'androidx.work:work-runtime' dependency in build.gradle.

**Multiplayer Enhancements:**
- **Stats Integration:**
    - Added recordMultiplayerWin/Loss/Draw methods to GameStats.
    - MultiplayerActivity now correctly calculates game duration and updates GameStats upon game completion.
    - Added saveStats() call in MultiplayerActivity.onPause to persist MP stats.
- **Animations:**
    - Implemented tile appearance and merge animations in MultiplayerActivity by comparing previous and current board states received via WebSocket.
- **Robustness:**
    - Added automatic WebSocket reconnection attempts with UI feedback in MultiplayerActivity.
    - Implemented finer-grained handling of server error messages (critical vs. info).
    - Added UI feedback for opponent disconnections (inferred from final game state).
    - Disabled swipe input during inappropriate times (opponent's turn, disconnected, game over).

**Layout Corrections:**
- Fixed duplicate ID 'average_time_per_game_label' in stats_layout.xml (renamed the multiplayer one to 'average_time_per_game_multi_label').
- Removed the unused 'perfect_game_label' TextView from stats_layout.xml.
- Updated MainActivity's updateStatisticsTextViews to use the corrected ID.

**Localization:**
- Translated all user-facing strings in strings.xml from French to English.
2025-04-06 14:50:40 +02:00

51 lines
1.3 KiB
Plaintext

plugins {
alias(libs.plugins.android.application)
}
android {
namespace = "legion.muyue.best2048"
compileSdk = 35
defaultConfig {
applicationId = "legion.muyue.best2048"
minSdk = 28
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
implementation(libs.activity.v190)
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
implementation(libs.gridlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
implementation(libs.retrofit)
implementation(libs.converter.gson)
implementation(libs.logging.interceptor)
implementation(libs.gson)
implementation(libs.okhttp)
implementation(libs.work.runtime)
}