Skip to content

Commit

Permalink
Merge pull request #4 from agstack/fix-dev-errors
Browse files Browse the repository at this point in the history
Fix dev errors
  • Loading branch information
lucienshema authored Dec 4, 2024
2 parents da641e1 + 95d5e7d commit 13de53b
Show file tree
Hide file tree
Showing 90 changed files with 2,688 additions and 1,105 deletions.
3 changes: 0 additions & 3 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .kotlin/errors/errors-1732630360041.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlin version: 2.0.20-RC
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
1. Kotlin compile daemon is ready

4 changes: 4 additions & 0 deletions .kotlin/errors/errors-1732799929492.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlin version: 2.0.20-RC
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
1. Kotlin compile daemon is ready

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,35 @@ Current Version: 2.36 (2024-10-16)

The project is under active development.

## Regression Test List

The regression test list is now available in the [Google Sheet](https://docs.google.com/spreadsheets/d/1X4InFUmJCyVf01pmEjwMyY8Gl45x1ODZGNvj7CFJCD4/edit?usp=sharing). This sheet contains the test cases and expected behaviors for all major features of the app. Testers can update their feedback directly in the sheet to indicate whether the feature works as expected.

### How to Use the Regression Test List

Once you make any updates or changes to the code, it is important to ensure that the new changes do not break any existing functionality. You can do this by referring to the regression test list in the Google Sheet, which helps you verify that everything is still working as expected.

1. **Click on the link to open the Google Sheet.**
2. **Create a new sheet** within the Google Sheet and name it with your tester name (e.g., "Tester: John Doe").
3. **Review the test cases** in the sheet and identify the tests that apply to the updated functionality.
4. **Execute the test cases** either manually or via automated tests (if applicable).
5. **Fill in the columns** in your newly created sheet with your feedback:
- `Test Case`: The name of the test case.
- `Expected Behavior`: The expected behavior for the feature.
- `Behavior Found`: What behavior was observed during testing.
- `Status`: Whether the test passed or failed (Mark as `Pass` or `Fail`).
- `Comments`: Any additional comments or observations.
6. **Update the status and comments** in the sheet directly after testing. This way, the whole team can track the feedback in real-time.

### Testers' Feedback

Testers can access the Google Sheet to enter their feedback after running the tests. This will help us track the stability of the app after each update and ensure that no functionality is broken.

### Instructions:
- After making any changes to the app (e.g., bug fixes, new features, refactoring), run the tests in the regression test list in the Google Sheet to confirm that the update did not introduce any issues or regressions.
- You can update the test list if needed if new scenarios or features are added.

By following this process, you ensure that your application remains stable and that any new changes do not break existing functionality.

---
*TerraTrac is committed to improving agricultural management through technology.*
36 changes: 27 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId "org.technoserve.farmcollector"
minSdk 21
targetSdk 35
versionCode 51
versionName "2.37"
versionCode 53
versionName "2.39"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
Expand Down Expand Up @@ -98,6 +98,11 @@ android {
testOptions {
unitTests {
includeAndroidResources = true
// all {
// systemProperty 'robolectric.enabledSdks', '33'
// systemProperty 'robolectric.build.model', 'DEVICE'
// environment 'BUILD_FINGERPRINT', 'foo'
// }
}
}

Expand Down Expand Up @@ -125,8 +130,9 @@ dependencies {
implementation("androidx.compose.material3:material3:1.3.1")
implementation("androidx.compose.material3:material3-window-size-class:1.3.1")
implementation 'com.google.android.gms:play-services-ads-identifier:18.1.0'
implementation 'androidx.work:work-runtime-ktx:2.10.0'
implementation 'androidx.work:work-runtime:2.8.0'
// implementation 'androidx.work:work-runtime-ktx:2.10.0'
implementation 'androidx.work:work-runtime-ktx:2.9.0'
// implementation 'androidx.work:work-runtime:2.8.0'


// camera dependencies
Expand Down Expand Up @@ -159,7 +165,7 @@ dependencies {

// Room

def room_version = "2.7.0-alpha01"
def room_version = "2.6.1"
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
//noinspection GradleDependency
Expand All @@ -185,7 +191,7 @@ dependencies {
ksp "com.google.dagger:hilt-compiler:2.51.1"
implementation "androidx.documentfile:documentfile:1.0.1"

def appcompat_version = "1.7.0"
def appcompat_version = "1.6.1"
implementation("androidx.appcompat:appcompat:$appcompat_version")
implementation("androidx.appcompat:appcompat-resources:$appcompat_version")
implementation("com.google.code.gson:gson:2.10.1")
Expand Down Expand Up @@ -213,18 +219,30 @@ dependencies {
implementation 'androidx.navigation:navigation-testing:2.4.0-alpha04'
implementation 'androidx.test.ext:junit-ktx:1.2.1'

testImplementation "androidx.test:core:1.6.1"
testImplementation "androidx.test:core:1.5.0"
testImplementation "org.mockito:mockito-core:5.7.0"
testImplementation "org.mockito.kotlin:mockito-kotlin:5.3.1"
testImplementation "io.mockk:mockk:1.13.7"
testImplementation "org.robolectric:robolectric:4.10.3"
// testImplementation "org.robolectric:robolectric:4.10.3"
testImplementation 'com.google.dagger:hilt-android-testing:2.48'
testImplementation 'androidx.compose.ui:ui-test-junit4-android:1.7.5'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation "com.google.truth:truth:1.1.3"
testImplementation "io.mockk:mockk:1.13.7"
testImplementation "io.mockk:mockk-android:1.13.5"
testImplementation "org.robolectric:robolectric:4.9"
//testImplementation "org.robolectric:robolectric:4.9"
testImplementation("androidx.work:work-testing:2.8.1")

// testImplementation("junit:junit:4.13.2")
testImplementation("org.robolectric:robolectric:4.13")



// testImplementation "org.robolectric:robolectric:4.11.1"
testImplementation "androidx.test:core:1.5.0"
testImplementation "androidx.test.ext:junit:1.1.5"
testImplementation "androidx.compose.ui:ui-test-junit4:1.5.4"



androidTestImplementation "androidx.work:work-testing:2.7.1"
Expand Down
Binary file modified app/release/app-release.aab
Binary file not shown.
6 changes: 0 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
</intent-filter>
</activity>

<service
android:name=".database.sync.SyncService"
android:foregroundServiceType="dataSync"
android:permission="android.permission.FOREGROUND_SERVICE"
tools:ignore="ForegroundServicePermission" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down
40 changes: 27 additions & 13 deletions app/src/main/java/org/technoserve/farmcollector/FarmCollectorApp.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.technoserve.farmcollector

import android.app.Application
import android.util.Log
import androidx.work.Configuration
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
Expand All @@ -10,32 +11,45 @@ import androidx.work.WorkManager
import org.technoserve.farmcollector.database.helpers.ContextProvider
import org.technoserve.farmcollector.database.sync.SyncWorker
import java.util.concurrent.TimeUnit
/**
*
* This class initializes WorkManager and sets up a periodic sync job to fetch and update data from the server.
*
*/

//class FarmCollectorApp : Application(), Configuration.Provider {
class FarmCollectorApp : Application(){


class FarmCollectorApp : Application() {
override fun onCreate() {
super.onCreate()
ContextProvider.initialize(this)
// initializeWorkManager()
initializeWorkManager()
}

/*
private fun initializeWorkManager() {
val workRequest = PeriodicWorkRequestBuilder<SyncWorker>(2, TimeUnit.HOURS)
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
// Build the constraints for the work
val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED) // Requires a connected network
.build()

// Create the periodic work request
val workRequest = PeriodicWorkRequestBuilder<SyncWorker>(2, TimeUnit.MINUTES)
.setConstraints(constraints)
.build()

// Enqueue the periodic work with a unique name to avoid duplicate schedules
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
"sync_work_tag",
ExistingPeriodicWorkPolicy.UPDATE,
"sync_work_tag", // Unique name for the work
ExistingPeriodicWorkPolicy.UPDATE, // Replace if already exists
workRequest
)

Log.d("WorkManager", "WorkManager is initialized successfully")
}

*/
// // Provide the WorkManager configuration
// override val workManagerConfiguration: Configuration
// get() = Configuration.Builder()
// .setMinimumLoggingLevel(Log.DEBUG) // Set logging level
// .build()
}
109 changes: 91 additions & 18 deletions app/src/main/java/org/technoserve/farmcollector/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.app.Application
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
Expand Down Expand Up @@ -34,7 +35,7 @@ import androidx.navigation.compose.rememberNavController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState
import org.technoserve.farmcollector.viewmodels.AppUpdateViewModel
import org.technoserve.farmcollector.viewmodels.ExitConfirmationDialog
//import org.technoserve.farmcollector.viewmodels.ExitConfirmationDialog
import org.technoserve.farmcollector.viewmodels.FarmViewModel
import org.technoserve.farmcollector.viewmodels.FarmViewModelFactory
import org.technoserve.farmcollector.viewmodels.UpdateAlert
Expand All @@ -55,7 +56,19 @@ import org.technoserve.farmcollector.viewmodels.LanguageViewModelFactory
import java.util.Locale


// Constants for navigation routes
/**
*
* Constants for navigation routes. These are used to define the different screens in the app.
*
* For example, if you have a "Site" model with an "id" field, you could define routes like:
*
* const val SITE_LIST = "siteList"
* const val FARM_LIST = "farmList/{siteId}"
* const val ADD_FARM = "addFarm/{siteId}"
* const val ADD_SITE = "addSite"
* const val UPDATE_FARM = "updateFarm/{farmId}"
*
*/
object Routes {
const val HOME = "home"
const val SITE_LIST = "siteList"
Expand All @@ -67,7 +80,11 @@ object Routes {
const val SETTINGS = "settings"
}


/**
* MainActivity is the entry point for the Android app. It sets up the navigation graph,
* manages permissions, and initializes the language and map view models.
*
*/
class MainActivity : ComponentActivity() {
private lateinit var locationHelper: LocationHelper
private val viewModel: MapViewModel by viewModels()
Expand Down Expand Up @@ -114,12 +131,14 @@ class MainActivity : ComponentActivity() {
val navController = rememberNavController()
val context = LocalContext.current
var canExitApp by remember { mutableStateOf(false) }
// var showExitToast by remember { mutableStateOf(false) }

val currentLanguage by languageViewModel.currentLanguage.collectAsState()

val appUpdateViewModel: AppUpdateViewModel = viewModel()
val updateAvailable by appUpdateViewModel.updateAvailable.collectAsState()

var showExitDialog by remember { mutableStateOf(false) }
// var showExitDialog by remember { mutableStateOf(false) }


// Initialize update check
Expand All @@ -128,10 +147,31 @@ class MainActivity : ComponentActivity() {
}


// Handle back press
BackHandler {
showExitDialog = true
}
// // Handle back press
// BackHandler {
// if (canExitApp) {
// // Exit the app
// (context as? Activity)?.finish()
// } else {
// showExitToast = true
// canExitApp = true
// }
// }
//
//
// // Show exit toast with delay for reset
// if (showExitToast) {
// Toast.makeText(context, "Press back again to exit", Toast.LENGTH_SHORT).show()
//
// // Delay resetting `showExitToast` and `canExitApp`
// LaunchedEffect(showExitToast) {
// kotlinx.coroutines.delay(2000) // 2 seconds delay
// showExitToast = false
// canExitApp = false
// }
// }



// Update Alert
UpdateAlert(
Expand All @@ -145,12 +185,12 @@ class MainActivity : ComponentActivity() {
}
)

// Exit Confirmation
ExitConfirmationDialog(
showDialog = showExitDialog,
onDismiss = { showExitDialog = false },
onConfirm = { (context as? Activity)?.finish() }
)
// // Exit Confirmation
// ExitConfirmationDialog(
// showDialog = showExitDialog,
// onDismiss = { showExitDialog = false },
// onConfirm = { (context as? Activity)?.finish() }
// )



Expand Down Expand Up @@ -187,15 +227,48 @@ class MainActivity : ComponentActivity() {
navController = navController,
startDestination = Routes.HOME,
) {
// composable(Routes.HOME) {
// BackHandler(enabled = canExitApp) {
// (context as? Activity)?.finish()
// }
// LaunchedEffect(Unit) {
// canExitApp = true
// }
// Home(navController, languageViewModel, languages)
// }
composable(Routes.HOME) {
BackHandler(enabled = canExitApp) {
(context as? Activity)?.finish()
//val context = LocalContext.current
// var canExitApp by remember { mutableStateOf(false) }
var showExitToast by remember { mutableStateOf(false) }

// Handle back press with confirmation
BackHandler {
if (canExitApp) {
// Exit the app
(context as? Activity)?.finish()
} else {
showExitToast = true
canExitApp = true
}
}
LaunchedEffect(Unit) {
canExitApp = true

// Show exit toast and reset the state after a delay
if (showExitToast) {
// Show the toast
Toast.makeText(context, "Press back again to exit", Toast.LENGTH_SHORT).show()

// Reset `showExitToast` and `canExitApp` after 2 seconds
LaunchedEffect(Unit) {
kotlinx.coroutines.delay(2000) // 2 seconds delay
showExitToast = false
canExitApp = false
}
}

// Display Home Screen
Home(navController, languageViewModel, languages)
}

composable(Routes.SITE_LIST) {
LaunchedEffect(Unit) {
canExitApp = false
Expand Down
Loading

0 comments on commit 13de53b

Please sign in to comment.